run_benches 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env ion
  2. let PROJECT_DIR = $parent(@split($(cargo locate-project), '"')[3])
  3. let CARGO = $PROJECT_DIR/target/release/ion
  4. fn check_timing script:str chars:int
  5. let utime:float = 0.0
  6. for _ in 0..10
  7. let temp = @(time ${global::CARGO} $script >/dev/null)[1]
  8. let utime:float += $temp[..-1]
  9. end
  10. let utime /= 10
  11. let utime = $utime[..11]
  12. let script = $filename(script)
  13. let script_len utime_len = $len(script) $len(utime)
  14. echo $repeat(' ', $(( chars - script_len )))$script \
  15. $utime$repeat('0', $(( 11 - utime_len )))
  16. end
  17. fn script_width scripts[]
  18. let max_chars:int = 0
  19. for script in @scripts
  20. let chars:int = $len($filename(script))
  21. if test $max_chars -lt $chars
  22. let max_chars:int = $chars
  23. end
  24. end
  25. echo $max_chars
  26. end
  27. fn bench_values scripts[]
  28. let max_chars = $(script_width [@scripts])
  29. for file in @scripts
  30. check_timing $file $max_chars
  31. end
  32. end
  33. cd $PROJECT_DIR/examples
  34. if test $len(@args) -eq 1
  35. bench_values [ ./*.ion ]
  36. else
  37. bench_values [ @args[1..] ]
  38. end