Skip to content

Commit be75f7f

Browse files
committed
feat: gather run time, memory usage in same run
Use `time -v`.
1 parent f6f4457 commit be75f7f

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015, 2017 dbohdan
1+
Copyright (c) 2015, 2017, 2019 dbohdan
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

benchmark.tcl

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1-
#!/usr/bin/env tclsh
1+
#! /usr/bin/env tclsh
22
namespace eval benchmark {
3-
variable tclssg {../ssg.tcl}
3+
variable tclssg [expr {
4+
[info exists ::env(TCLSSG)] ?
5+
$::env(TCLSSG) :
6+
{../tclssg/ssg.tcl}
7+
}]
48
variable benchmarks [list benchmark1]
59
}
610

7-
proc ::benchmark::run-tclssg {prefix command args} {
8-
variable tclssg
9-
exec -ignorestderr -- {*}$prefix $tclssg $command {*}$args
11+
proc ::benchmark::run args {
12+
puts "> $args"
13+
exec -ignorestderr -- {*}$args >@ stdout
1014
}
1115

1216
proc ::benchmark::main {} {
1317
variable benchmarks
14-
puts "Tclssg version tested: [run-tclssg {} version]"
18+
variable tclssg
19+
20+
run $tclssg version
1521
foreach benchmark $benchmarks {
1622
for {set i 0} {$i < 3} {incr i} {
17-
run-tclssg time build [file join $benchmark input] > /dev/null
18-
}
19-
for {set i 0} {$i < 3} {incr i} {
20-
run-tclssg memusg build [file join $benchmark input] > /dev/null
23+
# You need GNU time(1) for the "-v" flag.
24+
run time -v $tclssg build [file join $benchmark input] |& \
25+
awk {/(time|CPU|set size)/}
2126
}
2227
}
2328
}

0 commit comments

Comments
 (0)