@@ -19,71 +19,40 @@ fn main() {
1919 println ('failed to update V' )
2020 return
2121 }
22- mut commit_hash := exec ('git rev-parse HEAD' )
23- commit_hash = commit_hash[..8 ]
24- if os.exists ('last_commit.txt' ) {
25- last_commit := os.read_file ('last_commit.txt' ) ?
26- if last_commit.trim_space () == commit_hash.trim_space () {
27- println ('No new commits to benchmark. Commit $commit_hash has already been processed.' )
28- return
29- }
30- commit_hash = last_commit.trim_space ()
31- }
22+ commit := exec ('git rev-parse HEAD' )[..8 ]
23+ // commit_hash = commit_hash[..8]
3224 if ! os.exists ('table.html' ) {
3325 os.create ('table.html' ) ?
3426 }
3527 mut table := os.read_file ('table.html' ) ?
36- /*
37- // Do nothing if it's already been processed.
38- if table.contains(commit_hash) {
39- println('Commit $commit_hash has already been processed')
40- return
41- }
42- */
43- last_commits := exec ('git log --pretty=format:"%h" -n 50' ).split ('\n ' )
44- // Fetch all unprocessed commits (commits after the last processed commit)
45- mut commits := []string {}
46- println ('!last_commit="$commit_hash "' )
47- if last_commits.len == 0 || last_commits[0 ] == commit_hash {
28+ if table.contains ('>$commit <' ) {
4829 println ('nothing to benchmark' )
4930 exit (1 )
5031 return
5132 }
52- for i, c in last_commits {
53- if c == commit_hash {
54- commits = last_commits[..i].reverse ()
55- break
56- }
57- }
58- println (last_commits)
59- if commits.len == 0 {
60- // Just benchmark the last commit if the tool hasn't been run for too long.
61- // commits = [commit_hash]
62- }
63- println ('Commits to benchmark:' )
64- println (commits)
65- for i, commit in commits {
66- message := exec ('git log --pretty=format:"%s " -n1 $commit ' )
67- println ('\n ${i + 1} /$commits.len Benchmarking commit $commit "$message "' )
68- // Build an optimized V
69- println ('Checking out ${commit} ...' )
70- exec ('git checkout $commit ' )
71- println (' Building vprod...' )
72- exec ('v -o $vdir /vprod -prod $vdir /cmd/v' )
73- diff1 := measure ('$vdir /vprod -cc clang -o v.c -show-timings $vdir /cmd/v' , 'v.c' )
74- diff2 := measure ('$vdir /vprod -cc clang -o v2 $vdir /cmd/v' , 'v2' )
75- diff3 := measure ('$vdir /vprod -x64 $vdir /cmd/tools/1mil.v' , 'x64 1mil' )
76- diff4 := measure ('$vdir /vprod -cc clang $vdir /examples/hello_world.v' , 'hello.v' )
77- vc_size := os.file_size ('v.c' ) / 1000
78- // parse/check/cgen
79- parse , check , cgen := measure_steps (vdir)
80- // println('Building V took ${diff}ms')
81- commit_date := exec ('git log -n1 --pretty="format:%at" $commit ' )
82- date := time.unix (commit_date.int ())
83- mut out := os.create ('table.html' ) ?
84- // Place the new row on top
85- table =
86- '<tr>
33+ // for i, commit in commits {
34+ message := exec ('git log --pretty=format:"%s " -n1 $commit ' )
35+ // println('\n${i + 1}/$commits.len Benchmarking commit $commit "$message"')
36+ println ('\n Benchmarking commit $commit "$message "' )
37+ // Build an optimized V
38+ // println('Checking out ${commit}...')
39+ // exec('git checkout $commit')
40+ println (' Building vprod...' )
41+ exec ('v -o $vdir /vprod -prod $vdir /cmd/v' )
42+ diff1 := measure ('$vdir /vprod -cc clang -o v.c -show-timings $vdir /cmd/v' , 'v.c' )
43+ diff2 := measure ('$vdir /vprod -cc clang -o v2 $vdir /cmd/v' , 'v2' )
44+ diff3 := measure ('$vdir /vprod -x64 $vdir /cmd/tools/1mil.v' , 'x64 1mil' )
45+ diff4 := measure ('$vdir /vprod -cc clang $vdir /examples/hello_world.v' , 'hello.v' )
46+ vc_size := os.file_size ('v.c' ) / 1000
47+ // parse/check/cgen
48+ parse , check , cgen := measure_steps (vdir)
49+ // println('Building V took ${diff}ms')
50+ commit_date := exec ('git log -n1 --pretty="format:%at" $commit ' )
51+ date := time.unix (commit_date.int ())
52+ mut out := os.create ('table.html' ) ?
53+ // Place the new row on top
54+ table =
55+ '<tr>
8756 <td>$date.format ()</td>
8857 <td><a target=_blank href="https://github.com/vlang/v/commit/$commit ">$commit </a></td>
8958 <td>$message </td>
@@ -96,20 +65,20 @@ fn main() {
9665 <td>${check} ms</td>
9766 <td>${cgen} ms</td>
9867 </tr>\n ' +
99- table.trim_space ()
100- out.writeln (table) ?
101- out.close ()
102- // Regenerate index.html
103- header := os.read_file ('header.html' ) ?
104- footer := os.read_file ('footer.html' ) ?
105- mut res := os.create ('index.html' ) ?
106- res.writeln (header) ?
107- res.writeln (table) ?
108- res.writeln (footer) ?
109- res.close ()
110- }
111- exec ('git checkout master' )
112- os.write_file ('last_commit.txt' , commits[commits.len - 1 ]) ?
68+ table.trim_space ()
69+ out.writeln (table) ?
70+ out.close ()
71+ // Regenerate index.html
72+ header := os.read_file ('header.html' ) ?
73+ footer := os.read_file ('footer.html' ) ?
74+ mut res := os.create ('index.html' ) ?
75+ res.writeln (header) ?
76+ res.writeln (table) ?
77+ res.writeln (footer) ?
78+ res.close ()
79+ // }
80+ // exec('git checkout master')
81+ // os.write_file('last_commit.txt', commits[commits.len - 1]) ?
11382}
11483
11584fn exec (s string ) string {
0 commit comments