mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 23:48:35 +02:00
Unit Tests - abbreviation, filter, benchmark
- Added tests for attribute abbreviation. - Added tests for filter permutation testing. - Added benchmark for ongoing performance measurement. - Mentioned test suite in docs. Why not?
This commit is contained in:
parent
6a7c66aa05
commit
3088e1ebe1
5 changed files with 370 additions and 0 deletions
96
src/tests/benchmark.t
Executable file
96
src/tests/benchmark.t
Executable file
|
@ -0,0 +1,96 @@
|
|||
#! /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 => 4;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bench.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"_forcecolor=1\n";
|
||||
close $fh;
|
||||
ok (-r 'bench.rc', 'Created bench.rc');
|
||||
}
|
||||
|
||||
# Do lots of things. Time it all.
|
||||
|
||||
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';
|
||||
|
||||
# Start the clock.
|
||||
my $start = time ();
|
||||
diag ("start=$start");
|
||||
|
||||
# Make a mess.
|
||||
for my $i (1 .. 1000)
|
||||
{
|
||||
my $project = $projects[rand % 8];
|
||||
my $priority = $priorities[rand % 3];
|
||||
my $tag = $tags[rand % 8];
|
||||
|
||||
qx{../task rc:bench.rc add project:$project priority:$priority +$tag $i $description};
|
||||
}
|
||||
diag ("1000 tasks added");
|
||||
|
||||
qx{../task rc:bench.rc /with/WITH/} for 1 .. 200;
|
||||
qx{../task rc:bench.rc done $_} for 201 .. 400;
|
||||
qx{../task rc:bench.rc start $_} for 401 .. 600;
|
||||
diag ("600 tasks altered");
|
||||
|
||||
# Report it all.
|
||||
qx{../task rc:bench.rc ls};
|
||||
qx{../task rc:bench.rc list};
|
||||
qx{../task rc:bench.rc list priority:H};
|
||||
qx{../task rc:bench.rc list +tag};
|
||||
qx{../task rc:bench.rc list project_A};
|
||||
qx{../task rc:bench.rc long};
|
||||
qx{../task rc:bench.rc completed};
|
||||
qx{../task rc:bench.rc history};
|
||||
qx{../task rc:bench.rc ghistory};
|
||||
|
||||
# Stop the clock.
|
||||
my $stop = time ();
|
||||
diag ("stop=$stop");
|
||||
diag ("total=" . ($stop - $start));
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'completed.data';
|
||||
ok (!-r 'completed.data', 'Removed completed.data');
|
||||
|
||||
unlink 'bench.rc';
|
||||
ok (!-r 'bench.rc', 'Removed bench.rc');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue