~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/bench/benchmark.pl

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Sun Microsystems, Inc. All rights reserved.  Use
 
2
# is subject to license terms.
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 2 of the License.
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
11
# General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
 
16
# USA
 
17
 
 
18
use lib 'lib';
 
19
 
 
20
use GenTest;
 
21
use GenTest::Executor;
 
22
use GenTest::App::Gendata;
 
23
use GenTest::Grammar;
 
24
use GenTest::Generator::FromGrammar;
 
25
use Time::HiRes;
 
26
 
 
27
my $arg = shift;
 
28
 
 
29
if ($arg eq 'grammar') {
 
30
########################################
 
31
    say("Benchmark $arg: FromGrammar->next()");
 
32
    
 
33
    my $grammar = GenTest::Grammar->new(grammar_file => 'bench/WL5004_sql.yy');
 
34
    
 
35
    my $generator = GenTest::Generator::FromGrammar->new(grammar => $grammar,
 
36
                                                         seed => 0);
 
37
    
 
38
    my $executor = GenTest::Executor->newFromDSN("dummy");
 
39
    $executor->init();
 
40
    $executor->cacheMetaData();
 
41
    
 
42
    my $start = Time::HiRes::time();
 
43
    foreach $i (0..50000) {
 
44
    $generator->next([$executor,undef]);
 
45
    }
 
46
    my $stop = Time::HiRes::time();
 
47
    open TM,">bench/grammar.dat";
 
48
    print TM "YVALUE = ".($stop - $start)."\n";
 
49
    close TM;
 
50
    
 
51
} elsif ($arg eq 'gendata') {
 
52
########################################
 
53
    say("benchmark $arg: Gendata->run()");
 
54
    
 
55
    my $gen = GenTest::App::Gendata->new(dsn => "dummy",
 
56
                                         spec_file => "bench/falcon_data_types.zz",
 
57
                                         rows => 5000,
 
58
                                         views => 1);
 
59
    
 
60
    
 
61
    my $start = Time::HiRes::time();
 
62
    my $status = $gen->run();
 
63
    my $stop = Time::HiRes::time();
 
64
    
 
65
    open TM,">bench/gendata.dat";
 
66
    print TM "YVALUE = ".($stop - $start)."\n";
 
67
    close TM;
 
68
} else {
 
69
    foreach my $b ('gendata','grammar') {
 
70
        say("----------------------------------------------");
 
71
        system("perl -d:DProf bench/benchmark.pl $b");
 
72
        say("Collecting profiling information");
 
73
        system("dprofpp -u");
 
74
    }
 
75
}