mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
new benchmark module + make the tests use it
This commit is contained in:

committed by
Alexander Medvednikov

parent
3325775944
commit
a45895a3af
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import compiler.tests.repl.runner
|
||||
import benchmark
|
||||
|
||||
fn test_the_v_compiler_can_be_invoked() {
|
||||
vexec := runner.full_path_to_v()
|
||||
@ -20,24 +21,20 @@ fn test_the_v_compiler_can_be_invoked() {
|
||||
|
||||
fn test_all_v_repl_files() {
|
||||
options := runner.new_options()
|
||||
global_start_time := runner.now()
|
||||
mut total_tests := 0
|
||||
mut ok_tests := 0
|
||||
mut failed_tests := 0
|
||||
mut bmark := benchmark.new_benchmark()
|
||||
for file in options.files {
|
||||
total_tests++
|
||||
sticks := runner.now()
|
||||
bmark.step()
|
||||
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
|
||||
failed_tests++
|
||||
bmark.fail()
|
||||
eprintln( bmark.step_message(err) )
|
||||
assert false
|
||||
eprintln( runner.tdiff_in_ms(err, sticks) )
|
||||
continue
|
||||
}
|
||||
bmark.ok()
|
||||
println( bmark.step_message(fres) )
|
||||
assert true
|
||||
println( runner.tdiff_in_ms(fres, sticks) )
|
||||
ok_tests++
|
||||
}
|
||||
println( runner.tdiff_in_ms('<=== total time spent running REPL files', global_start_time) )
|
||||
println( ' ok, failed, total : ${ok_tests:5d}, ${failed_tests:5d}, ${total_tests:5d}' )
|
||||
bmark.stop()
|
||||
println( bmark.total_message('total time spent running REPL files') )
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,23 @@ module main
|
||||
|
||||
import compiler.tests.repl.runner
|
||||
import log
|
||||
import benchmark
|
||||
|
||||
fn main(){
|
||||
logger := &log.Log{log.DEBUG, 'terminal'}
|
||||
options := runner.new_options()
|
||||
global_start_time := runner.now()
|
||||
|
||||
mut bmark := benchmark.new_benchmark()
|
||||
for file in options.files {
|
||||
stime := runner.now()
|
||||
bmark.step()
|
||||
fres := runner.run_repl_file(options.wd, options.vexec, file) or {
|
||||
logger.error( runner.tdiff_in_ms(err, stime) )
|
||||
bmark.fail()
|
||||
logger.error( bmark.step_message( err ) )
|
||||
continue
|
||||
}
|
||||
logger.info( runner.tdiff_in_ms(fres, stime) )
|
||||
bmark.ok()
|
||||
logger.info( bmark.step_message( fres ) )
|
||||
}
|
||||
logger.info( runner.tdiff_in_ms('<=== total time spent running REPL files', global_start_time) )
|
||||
bmark.stop()
|
||||
logger.info( bmark.total_message('total time spent running REPL files') )
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
module runner
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
struct RunnerOptions {
|
||||
pub:
|
||||
@ -71,13 +70,3 @@ pub fn new_options() RunnerOptions {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn now() i64 {
|
||||
return time.ticks()
|
||||
}
|
||||
|
||||
pub fn tdiff_in_ms(s string, sticks i64) string {
|
||||
eticks := time.ticks()
|
||||
tdiff := (eticks - sticks)
|
||||
return '${tdiff:6d} ms | $s'
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user