diff --git a/src/Timer.cpp b/src/Timer.cpp index 5e6326420..1c44fc644 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -52,7 +52,12 @@ Timer::~Timer () << mDescription << " " << std::setprecision (6) -// << std::fixed + +#ifndef HAIKU + // Haiku fails on this - don't know why. + << std::fixed +#endif + << ((end.tv_sec - mStart.tv_sec) + ((end.tv_usec - mStart.tv_usec ) / 1000000.0)) << " sec"; diff --git a/src/tests/benchmark.txt b/src/tests/benchmark.txt deleted file mode 100644 index 19f4c81c1..000000000 --- a/src/tests/benchmark.txt +++ /dev/null @@ -1,53 +0,0 @@ -3/8/2009 - Before: - Table::render - 26.1792 - 16.67 - 18.9697 - 28.6328 - 1.86553 - 0.00044 - 0.000319 - --------- - 92.317989 - - After Table::optimize removed: - Table::render - 0.146177 - 0.145928 - 0.184444 - 0.014784 - 0.000512 - 0.000267 - --------- - 0.492112 - - Speedup: - 92.317989 / 0.492112 = 187.6 - -3/8/2009 - New benchmark: - 1..4 - ok 1 - Created bench.rc - # start=1236565862 - # 1000 tasks added in 3 seconds - # 600 tasks altered in 28 seconds - # stop=1236566048 - # total=186 - ok 2 - Removed pending.data - ok 3 - Removed completed.data - ok 4 - Removed bench.rc - -6/18/2009 - 1.8.0: - 1..4 - ok 1 - Created bench.rc - # start=1245372501 - # 1000 tasks added in 4 seconds - # 600 tasks altered in 45 seconds - # stop=1245372747 - # total=246 - ok 2 - Removed pending.data - ok 3 - Removed completed.data - ok 4 - Removed bench.rc - diff --git a/src/tests/benchmark2.t b/src/tests/benchmark2.t new file mode 100755 index 000000000..94dc2cfde --- /dev/null +++ b/src/tests/benchmark2.t @@ -0,0 +1,124 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2009, Paul Beckingham. +## All rights reserved. +## +## 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 2 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, write to the +## +## Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, +## Boston, MA +## 02110-1301 +## USA +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 5; + +# Create the rc file. +if (open my $fh, '>', 'bench2.rc') +{ + print $fh "data.location=.\n", + "_forcecolor=1\n", + "debug=on\n"; + close $fh; + ok (-r 'bench2.rc', 'Created bench2.rc'); +} + +# Data. +my @tags = qw(t_one t_two t_three t_four t_five t_six t_seven t_eight); +my @projects = qw(p_one p_two p_three p_foud p_five p_six p_seven p_eight); +my @priorities = qw(H M L); +my $description = 'This is a medium-sized description with no special characters'; + +my $output; + +# Add 10 tasks. +add (10); +$output = qx{../task rc:bench2.rc list}; +report ('run-10', $output); + +# Add 90 more tasks. +add (90); +$output = qx{../task rc:bench2.rc list}; +report ('run-100', $output); + +# Add 900 more tasks. +add (900); +$output = qx{../task rc:bench2.rc list}; +report ('run-1000', $output); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'bench2.rc'; +ok (!-r 'bench2.rc', 'Removed bench2.rc'); + +exit 0; + +################################################################################ +sub add +{ + my ($quantity) = @_; + + for my $i (1 .. $quantity) + { + my $project = $projects[rand % 8]; + my $priority = $priorities[rand % 3]; + my $tag = $tags[rand % 8]; + + qx{../task rc:bench2.rc add project:$project priority:$priority +$tag $i $description}; + } +} + +################################################################################ +sub report +{ + my ($label, $output) = @_; + + my %data; + while ($output =~ /^Timer (\S+) ([0-9.e-]+)/msg) + { + $data{$1} += $2; + } + + # Generate output for benchmark2 chart. + chomp (my $version = qx{../task _version}); + my $out = sprintf "%s %s %f,%f,%f,%f,%f,%f,%f", + $label, + $version, + $data{'Context::initialize'}, + $data{'Context::parse'}, + $data{'TDB::loadPending'}, + $data{'TDB::loadCompleted'}, + $data{'TDB::gc'}, + $data{'TDB::commit'}, + $data{'Table::render'}; + + diag ($out); +} + +################################################################################ +