Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
clang-hash
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Christian Dietrich
clang-hash
Commits
10a2a840
There was a problem fetching the pipeline summary.
Commit
10a2a840
authored
Aug 29, 2016
by
Ludwig Fueracker
Browse files
Options
Downloads
Patches
Plain Diff
replaced string keys with numbers to save memory
parent
3252e7f7
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
validate_hashes.py
+74
-30
74 additions, 30 deletions
validate_hashes.py
with
74 additions
and
30 deletions
validate_hashes.py
+
74
−
30
View file @
10a2a840
...
@@ -79,6 +79,41 @@ def validateHashes(recordList):
...
@@ -79,6 +79,41 @@ def validateHashes(recordList):
#
#
################################################################################
################################################################################
keyTranslationToNr
=
{
'
start-time
'
:
0
,
'
hash-start-time
'
:
1
,
'
object-hash
'
:
2
,
'
return-code
'
:
3
,
'
parse-duration
'
:
4
,
'
object-file-size
'
:
5
,
'
processed-bytes
'
:
6
,
'
hash-duration
'
:
7
,
'
filename
'
:
8
,
'
project
'
:
9
,
'
compile-duration
'
:
10
,
'
ast-hash
'
:
11
,
'
commit-hash
'
:
12
,
'
element-hashes
'
:
13
,
'
commit-time
'
:
14
,
'
build-time
'
:
15
,
'
files
'
:
16
,
'
filesChanged
'
:
17
,
'
insertions
'
:
18
,
'
deletions
'
:
19
,
'
time
'
:
200
#backwards compatibility, remove
}
keyTranslationFromNr
=
{
v
:
k
for
k
,
v
in
keyTranslationToNr
.
items
()}
keyTranslation
=
keyTranslationToNr
.
copy
()
keyTranslation
.
update
(
keyTranslationFromNr
)
def
tr
(
key
):
return
keyTranslation
[
key
]
def
buildFullRecordTo
(
pathToFullRecordFile
):
def
buildFullRecordTo
(
pathToFullRecordFile
):
fullRecord
=
{}
fullRecord
=
{}
# this leads to being Killed by OS due to tremendous memory consumtion...
# this leads to being Killed by OS due to tremendous memory consumtion...
...
@@ -108,9 +143,18 @@ def buildFullRecord():
...
@@ -108,9 +143,18 @@ def buildFullRecord():
The records are grouped by the commitIDs
'''
The records are grouped by the commitIDs
'''
fullRecord
=
{}
fullRecord
=
{}
with
open
(
pathToRecords
+
COMMITINFOFILENAME
,
'
r
'
)
as
commitInfoFile
:
with
open
(
pathToRecords
+
COMMITINFOFILENAME
,
'
r
'
)
as
commitInfoFile
:
fullRecord
=
eval
(
commitInfoFile
.
read
())
commitInfo
=
eval
(
commitInfoFile
.
read
())
for
commitID
in
fullRecord
:
for
commitID
in
commitInfo
:
fullRecord
[
commitID
][
'
files
'
]
=
{}
fullRecord
[
commitID
]
=
{}
fullRecord
[
commitID
][
tr
(
'
commit-time
'
)]
=
commitInfo
[
commitID
][
'
commit-time
'
]
fullRecord
[
commitID
][
tr
(
'
build-time
'
)]
=
commitInfo
[
commitID
][
'
build-time
'
]
fullRecord
[
commitID
][
tr
(
'
files
'
)]
=
{}
fullRecord
[
commitID
][
tr
(
'
filesChanged
'
)]
=
commitInfo
[
commitID
][
'
filesChanged
'
]
#TODO: rename files-changed
if
'
insertions
'
in
commitInfo
[
commitID
]:
fullRecord
[
commitID
][
tr
(
'
insertions
'
)]
=
commitInfo
[
commitID
][
'
insertions
'
]
if
'
deletions
'
in
commitInfo
[
commitID
]:
fullRecord
[
commitID
][
tr
(
'
deletions
'
)]
=
commitInfo
[
commitID
][
'
deletions
'
]
for
recordFilename
in
getListOfFiles
(
pathToRecords
):
for
recordFilename
in
getListOfFiles
(
pathToRecords
):
for
line
in
open
(
recordFilename
):
for
line
in
open
(
recordFilename
):
...
@@ -119,14 +163,15 @@ def buildFullRecord():
...
@@ -119,14 +163,15 @@ def buildFullRecord():
del
data
[
'
commit-hash
'
]
del
data
[
'
commit-hash
'
]
filename
=
data
[
'
filename
'
]
filename
=
data
[
'
filename
'
]
del
data
[
'
filename
'
]
del
data
[
'
filename
'
]
fullRecord
[
commitID
][
'
files
'
][
filename
]
=
data
dataNewKeys
=
{
tr
(
k
):
v
for
k
,
v
in
data
.
items
()}
fullRecord
[
commitID
][
tr
(
'
files
'
)][
filename
]
=
dataNewKeys
return
fullRecord
return
fullRecord
################################################################################
################################################################################
def
getSortedCommitIDList
(
fullRecord
):
def
getSortedCommitIDList
(
fullRecord
):
return
sorted
(
fullRecord
,
key
=
lambda
x
:
(
fullRecord
[
x
][
'
commit-time
'
]))
return
sorted
(
fullRecord
,
key
=
lambda
x
:
(
fullRecord
[
x
][
tr
(
'
commit-time
'
)
]))
################################################################################
################################################################################
...
@@ -149,14 +194,14 @@ def makeBuildTimeGraph(fullRecord):
...
@@ -149,14 +194,14 @@ def makeBuildTimeGraph(fullRecord):
currentCommit
=
fullRecord
[
commitID
]
currentCommit
=
fullRecord
[
commitID
]
totalOptimalRedundantCompileTime
=
0
# ns
totalOptimalRedundantCompileTime
=
0
# ns
totalASTHashRedundantCompileTime
=
0
# ns
totalASTHashRedundantCompileTime
=
0
# ns
currentFiles
=
currentCommit
[
'
files
'
]
currentFiles
=
currentCommit
[
tr
(
'
files
'
)
]
prevFiles
=
prevCommit
[
'
files
'
]
prevFiles
=
prevCommit
[
tr
(
'
files
'
)
]
compileTimeOnly
=
0
# ns
compileTimeOnly
=
0
# ns
totalParsingTime
=
0
# ns
totalParsingTime
=
0
# ns
totalHashingTime
=
0
# ns
totalHashingTime
=
0
# ns
for
filename
in
currentFiles
:
for
filename
in
currentFiles
:
if
'
ast-hash
'
not
in
currentFiles
[
filename
].
keys
():
if
tr
(
'
ast-hash
'
)
not
in
currentFiles
[
filename
].
keys
():
break
break
if
filename
not
in
prevFiles
:
if
filename
not
in
prevFiles
:
break
break
...
@@ -164,17 +209,17 @@ def makeBuildTimeGraph(fullRecord):
...
@@ -164,17 +209,17 @@ def makeBuildTimeGraph(fullRecord):
currentRecord
=
currentFiles
[
filename
]
currentRecord
=
currentFiles
[
filename
]
prevRecord
=
prevFiles
[
filename
]
prevRecord
=
prevFiles
[
filename
]
compileDuration
=
currentRecord
[
'
compile-duration
'
]
/
10
# ns #TODO: /10-BUG
compileDuration
=
currentRecord
[
tr
(
'
compile-duration
'
)]
# /20 # ns
compileTimeOnly
+=
compileDuration
# ns
compileTimeOnly
+=
compileDuration
# ns
totalParsingTime
+=
currentRecord
[
'
parse-duration
'
]
# ns
totalParsingTime
+=
currentRecord
[
tr
(
'
parse-duration
'
)]
# /20
# ns
totalHashingTime
+=
currentRecord
[
'
hash-duration
'
]
# ns
totalHashingTime
+=
currentRecord
[
tr
(
'
hash-duration
'
)
]
# ns
if
prevRecord
[
'
object-hash
'
]
==
currentRecord
[
'
object-hash
'
]:
if
prevRecord
[
tr
(
'
object-hash
'
)
]
==
currentRecord
[
tr
(
'
object-hash
'
)
]:
totalOptimalRedundantCompileTime
+=
compileDuration
#ns
totalOptimalRedundantCompileTime
+=
compileDuration
#ns
if
prevRecord
[
'
ast-hash
'
]
==
currentRecord
[
'
ast-hash
'
]:
if
prevRecord
[
tr
(
'
ast-hash
'
)
]
==
currentRecord
[
tr
(
'
ast-hash
'
)
]:
totalASTHashRedundantCompileTime
+=
compileDuration
# ns
totalASTHashRedundantCompileTime
+=
compileDuration
# ns
buildTime
=
currentCommit
[
'
build-time
'
]
/
10
# ns #TODO: /10-BUG
buildTime
=
currentCommit
[
tr
(
'
build-time
'
)
]
# ns
optimalBuildTime
=
buildTime
-
totalOptimalRedundantCompileTime
# = buildTime - sum(compileTime(file) if objhash(file) unchanged)
optimalBuildTime
=
buildTime
-
totalOptimalRedundantCompileTime
# = buildTime - sum(compileTime(file) if objhash(file) unchanged)
astHashBuildTime
=
buildTime
-
totalASTHashRedundantCompileTime
# = buildTime - sum(compileTime(file) if asthash(file) unchanged)
astHashBuildTime
=
buildTime
-
totalASTHashRedundantCompileTime
# = buildTime - sum(compileTime(file) if asthash(file) unchanged)
...
@@ -221,18 +266,17 @@ def makeChangesGraph(fullRecord):
...
@@ -221,18 +266,17 @@ def makeChangesGraph(fullRecord):
# f_changes.write("%s;%s;%s;%s\n" % ("commitHash", "differentAstHash", "differentObjHash", "same"))
# f_changes.write("%s;%s;%s;%s\n" % ("commitHash", "differentAstHash", "differentObjHash", "same"))
for
commitID
in
iterCommits
:
for
commitID
in
iterCommits
:
print
commitID
currentCommit
=
fullRecord
[
commitID
]
currentCommit
=
fullRecord
[
commitID
]
currentFiles
=
currentCommit
[
'
files
'
]
currentFiles
=
currentCommit
[
tr
(
'
files
'
)
]
prevFiles
=
prevCommit
[
'
files
'
]
prevFiles
=
prevCommit
[
tr
(
'
files
'
)
]
same
=
0
same
=
0
differentAstHash
=
0
differentAstHash
=
0
differentObjHash
=
0
differentObjHash
=
0
fileCount
=
0
fileCount
=
0
for
filename
in
currentFiles
:
for
filename
in
currentFiles
:
if
'
ast-hash
'
not
in
currentFiles
[
filename
].
keys
():
if
tr
(
'
ast-hash
'
)
not
in
currentFiles
[
filename
].
keys
():
if
filename
[
-
2
:]
!=
'
.s
'
:
if
filename
[
-
2
:]
!=
'
.s
'
:
print
"
ast-hash not in keys of file
"
+
filename
print
"
ast-hash not in keys of file
"
+
filename
continue
continue
...
@@ -247,10 +291,10 @@ def makeChangesGraph(fullRecord):
...
@@ -247,10 +291,10 @@ def makeChangesGraph(fullRecord):
else
:
else
:
prevRecord
=
prevFiles
[
filename
]
prevRecord
=
prevFiles
[
filename
]
if
prevRecord
[
'
object-hash
'
]
!=
currentRecord
[
'
object-hash
'
]:
if
prevRecord
[
tr
(
'
object-hash
'
)
]
!=
currentRecord
[
tr
(
'
object-hash
'
)
]:
differentObjHash
+=
1
differentObjHash
+=
1
differentAstHash
+=
1
differentAstHash
+=
1
elif
prevRecord
[
'
ast-hash
'
]
!=
currentRecord
[
'
ast-hash
'
]:
elif
prevRecord
[
tr
(
'
ast-hash
'
)
]
!=
currentRecord
[
tr
(
'
ast-hash
'
)
]:
differentAstHash
+=
1
differentAstHash
+=
1
else
:
else
:
same
+=
1
same
+=
1
...
@@ -288,8 +332,8 @@ if (len(sys.argv) > 1):
...
@@ -288,8 +332,8 @@ if (len(sys.argv) > 1):
pathToFullRecordFile
=
pathToRecords
+
FULLRECORDFILENAME
pathToFullRecordFile
=
pathToRecords
+
FULLRECORDFILENAME
print
"
Starting at %s
"
%
time
.
ctime
()
print
"
Starting at %s
"
%
time
.
ctime
()
validateRecords
()
#
validateRecords()
print
"
finished validating at %s
"
%
time
.
ctime
()
#
print "finished validating at %s" % time.ctime()
fullRecord
=
buildFullRecordTo
(
pathToFullRecordFile
)
fullRecord
=
buildFullRecordTo
(
pathToFullRecordFile
)
print
"
finished building/loading full record at %s
"
%
time
.
ctime
()
print
"
finished building/loading full record at %s
"
%
time
.
ctime
()
...
@@ -297,8 +341,8 @@ if (len(sys.argv) > 1):
...
@@ -297,8 +341,8 @@ if (len(sys.argv) > 1):
makeBuildTimeGraph
(
fullRecord
)
makeBuildTimeGraph
(
fullRecord
)
print
"
finished BuildTimeGraph at %s
"
%
time
.
ctime
()
print
"
finished BuildTimeGraph at %s
"
%
time
.
ctime
()
makeChangesGraph
(
fullRecord
)
#
makeChangesGraph(fullRecord)
print
"
finished ChangesGraph at %s
"
%
time
.
ctime
()
#
print "finished ChangesGraph at %s" % time.ctime()
print
"
Finished at %s
"
%
time
.
ctime
()
print
"
Finished at %s
"
%
time
.
ctime
()
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment