From e85a7653e8ca1da1bd55ded062916105a5ed1ab8 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sat, 29 Mar 2014 11:16:14 -0400 Subject: [PATCH] Generic performance test output Styled for display to user as the tests are running, but data are written to perf.out for additional processing. You can style the perf.out file cleanly using: $ column -ts\| perf.out --- .gitignore | 4 ++++ Makefile.am | 5 ++--- configure.ac | 7 ++++--- test/perf/common.js | 4 +--- test/perf/runner.in | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 9 deletions(-) create mode 100755 test/perf/runner.in diff --git a/.gitignore b/.gitignore index f0d5048..e96f874 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ ChangeLog # autotools- and configure-generated test/runner +test/perf/runner aclocal.m4 Makefile.in Makefile @@ -17,6 +18,9 @@ Makefile configure config.* +# script output +perf.out + # should be added using autoreconf -i INSTALL tools/install-sh diff --git a/Makefile.am b/Makefile.am index 752c710..fadc540 100644 --- a/Makefile.am +++ b/Makefile.am @@ -112,10 +112,9 @@ test: check check: $(src_tests) test-suite # performance tests -perf: @PERF_TESTS@ -perf-%.js: FORCE +perf: if HAS_NODE - @$(NODE) $@ + @$(path_test)/perf/runner @PERF_TESTS@ else @echo "Node.js must be installed in order to run performance tests" @exit 1 diff --git a/configure.ac b/configure.ac index 3bc5bb4..783e0a4 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,8 @@ PERF_TESTS=$( find test/perf -name 'perf-*.js' | tr '\n' ' ' ) AC_SUBST(PERF_TESTS) AS_IF([test "$PERF_TESTS"], [AC_MSG_RESULT(ok)], [AC_MSG_WARN(none found)]) -AC_CONFIG_FILES( - [Makefile doc/Makefile package.json lib/version.js test/runner], - [chmod +x test/runner]) +AC_CONFIG_FILES([Makefile doc/Makefile package.json lib/version.js]) +AC_CONFIG_FILES([test/runner], [chmod +x test/runner]) +AC_CONFIG_FILES([test/perf/runner], [chmod +x test/perf/runner]) + AC_OUTPUT diff --git a/test/perf/common.js b/test/perf/common.js index 324f05d..13c1d46 100644 --- a/test/perf/common.js +++ b/test/perf/common.js @@ -89,8 +89,6 @@ exports.report = function( count, desc ) pers = ( total / count ).toFixed( 10 ) ; - console.log( total + "s (x" + count + " = " + pers + "s each)" + - ( ( desc ) ? ( ': ' + desc ) : '' ) - ); + console.log( "%s|%s|%s|%s", desc, count, pers, total ); }; diff --git a/test/perf/runner.in b/test/perf/runner.in new file mode 100755 index 0000000..1fe846f --- /dev/null +++ b/test/perf/runner.in @@ -0,0 +1,36 @@ +#!/bin/sh +# +# Copyright (C) 2014 Mike Gerwitz +# +# This file is part of GNU ease.js. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# If you want formatted output, see :/tools/perf2html, or run this command: +# $ column -ts\| perf.out +# # + +rawout=perf.out +>"$rawout" + +for f in "$@"; do + @NODE@ "$f" || exit $? +done \ + | tee -a "$rawout" \ + | awk -F\| ' + # format for display as the tests are running + { printf "%s (x%s = %ss each): %s\n", $4, $2, $3, $1 } + ' + +echo "Raw data written to $rawout" >&2