mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-30 22:43:24 +02:00
Unit Tests - benchmark2
- Fixed Timer class to use a fixed precision, that for some reason, does not work on Haiku. Put a conditional compile around it for now - perhaps later Haiku alpha releases will change things? - Added benchmark2.t, which enables high-resolution timers for a single 'list' command, with 10, 100 and 1000 task databases. Then it emits readily-found and parsed data for charts. - Eliminated obsolete benchmark data for hardware I no longer own.
This commit is contained in:
parent
f43e093515
commit
5ef3bcc243
3 changed files with 130 additions and 54 deletions
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
|
124
src/tests/benchmark2.t
Executable file
124
src/tests/benchmark2.t
Executable file
|
@ -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);
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue