mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
ci: add .github/workflows/compare_pr_to_master.v
This commit is contained in:
parent
b7c6054319
commit
947da2b811
1 changed files with 74 additions and 0 deletions
74
.github/workflows/compare_pr_to_master.v
vendored
Executable file
74
.github/workflows/compare_pr_to_master.v
vendored
Executable file
|
@ -0,0 +1,74 @@
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
const compare_prod = '-prod' in os.args
|
||||||
|
|
||||||
|
fn gbranch() string {
|
||||||
|
return os.execute(r'git branch --list|grep ^\*').output.trim_space()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gcommit() string {
|
||||||
|
return os.execute(r'git rev-parse --short=7 HEAD').output.trim_space()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn r(cmd string) {
|
||||||
|
os.system(cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn xtime(cmd string) {
|
||||||
|
$if windows {
|
||||||
|
before := time.now()
|
||||||
|
r(cmd)
|
||||||
|
after := time.now()
|
||||||
|
delta_time := after - before
|
||||||
|
println('> Elapsed time: ${delta_time.milliseconds()} ms, for cmd: ${cmd}')
|
||||||
|
} $else {
|
||||||
|
r('/usr/bin/time -f "CPU: %Us\tReal: %es\tElapsed: %E\tRAM: %MKB\t%C" ${cmd}')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn vcompare(vold string, vnew string) {
|
||||||
|
r("v repeat -R 3 '${vold} -check-syntax examples/hello_world.v' '${vnew} -check-syntax examples/hello_world.v'")
|
||||||
|
r("v repeat -R 3 '${vold} -check examples/hello_world.v' '${vnew} -check examples/hello_world.v'")
|
||||||
|
r("v repeat -R 3 '${vold} -o hw.c examples/hello_world.v' '${vnew} -o hw.c examples/hello_world.v'")
|
||||||
|
r("v repeat -R 3 '${vold} -o hw examples/hello_world.v' '${vnew} -o hw examples/hello_world.v'")
|
||||||
|
r("v repeat -R 3 '${vold} -check-syntax cmd/v' '${vnew} -check-syntax cmd/v'")
|
||||||
|
r("v repeat -R 3 '${vold} -check cmd/v' '${vnew} -check cmd/v'")
|
||||||
|
r("v repeat -R 3 '${vold} -o ov.c cmd/v' '${vnew} -o nv.c cmd/v'")
|
||||||
|
r("v repeat -R 3 '${vold} -o ov cmd/v' '${vnew} -o nv cmd/v'")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// The starting point, when this program should be started, is just after `gh pr checkout NUMBER`.
|
||||||
|
|
||||||
|
println('Current git branch: ${gbranch()}, commit: ${gcommit()}')
|
||||||
|
println(' Compiling new V executables from PR branch: ${gbranch()}, commit: ${gcommit()} ...')
|
||||||
|
xtime('./v -o vnew1 cmd/v')
|
||||||
|
xtime('./vnew1 -o vnew2 cmd/v')
|
||||||
|
xtime('./vnew2 -o vnew cmd/v')
|
||||||
|
r('rm -rf vnew1 vnew2')
|
||||||
|
if compare_prod {
|
||||||
|
xtime('./vnew -prod -o vnew_prod cmd/v')
|
||||||
|
}
|
||||||
|
|
||||||
|
r('git checkout master')
|
||||||
|
|
||||||
|
println(' Compiling old V executables from branch: ${gbranch()}, commit: ${gcommit()} ...')
|
||||||
|
xtime('./v -o vold1 cmd/v')
|
||||||
|
xtime('./vold1 -o vold2 cmd/v')
|
||||||
|
xtime('./vold2 -o vold cmd/v')
|
||||||
|
r('rm -rf vold1 vold2')
|
||||||
|
if compare_prod {
|
||||||
|
xtime('./vold -prod -o vold_prod cmd/v')
|
||||||
|
}
|
||||||
|
|
||||||
|
r('git switch -') // we are on the PR branch again
|
||||||
|
|
||||||
|
println(' Measuring at PR branch: ${gbranch()}, commit: ${gcommit()} ...')
|
||||||
|
if compare_prod {
|
||||||
|
vcompare('./vold_prod', './vnew_prod')
|
||||||
|
} else {
|
||||||
|
vcompare('./vold', './vnew')
|
||||||
|
}
|
||||||
|
println('Done.')
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue