[Bps-public-commit] r15812 - in Data-Hierarchy/trunk: .

clkao at bestpractical.com clkao at bestpractical.com
Mon Sep 8 07:04:21 EDT 2008


Author: clkao
Date: Mon Sep  8 07:04:21 2008
New Revision: 15812

Added:
   Data-Hierarchy/trunk/t/7performance.t   (contents, props changed)
Modified:
   Data-Hierarchy/trunk/   (props changed)

Log:
 r35448 at mtl (orig r383):  glasser | 2006-11-03 10:30:43 +0800
 Add a (failing) performance test.  (Current value: ~2.8.)
 


Added: Data-Hierarchy/trunk/t/7performance.t
==============================================================================
--- (empty file)
+++ Data-Hierarchy/trunk/t/7performance.t	Mon Sep  8 07:04:21 2008
@@ -0,0 +1,41 @@
+#!/usr/bin/env perl
+
+use Test::More tests => 2;
+use Benchmark;
+
+BEGIN {
+    use_ok 'Data::Hierarchy';
+}
+
+use constant ITERATIONS => 2;
+use constant MULTIPLIER => 3;
+use constant N => 200;
+
+# Returns the power of n that $code grows by.
+sub order_of_growth {
+    my $n = shift;
+    my $code = shift;
+
+    my $time_small = timeit(ITERATIONS, sub { $code->($n) });
+    my $time_large = timeit(ITERATIONS, sub { $code->($n * MULTIPLIER) });
+
+    # use 'user' time
+    my $ratio = $time_large->[1]/$time_small->[0];
+
+    return log($ratio)/log(MULTIPLIER);
+}
+
+my $growth = order_of_growth(N, sub {
+                                 my $n = shift;
+                                 diag "doing $n";
+                                 
+                                 my $d = Data::Hierarchy->new;
+                                 my $kv = { foo => 'bar' };
+                                 while ($n > 0) {
+                                     $n--;
+                                     $d->store("/A/$n", $kv);
+                                 }
+                                 $d->store("/A", $kv);
+                             });
+
+is ($growth < 1.5, "Data::Hierarchy scales poorly: $growth");



More information about the Bps-public-commit mailing list