Changeset 23406 for docs/hidek

Show
Ignore:
Timestamp:
11/12/08 20:21:36 (5 years ago)
Author:
hidek
Message:

update NanoA benchmark

Location:
docs/hidek/bench/nanoa
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • docs/hidek/bench/nanoa/benchmark.out

    r23397 r23406  
    1414 
    1515Concurrency Level:      100 
    16 Time taken for tests:   19.393726 seconds 
     16Time taken for tests:   19.531023 seconds 
    1717Complete requests:      1000 
    1818Failed requests:        0 
    1919Write errors:           0 
    20 Total transferred:      156720 bytes 
     20Total transferred:      142680 bytes 
    2121HTML transferred:       10000 bytes 
    22 Requests per second:    51.56 [#/sec] (mean) 
    23 Time per request:       1939.373 [ms] (mean) 
    24 Time per request:       19.394 [ms] (mean, across all concurrent requests) 
    25 Transfer rate:          7.89 [Kbytes/sec] received 
     22Requests per second:    51.20 [#/sec] (mean) 
     23Time per request:       1953.102 [ms] (mean) 
     24Time per request:       19.531 [ms] (mean, across all concurrent requests) 
     25Transfer rate:          7.12 [Kbytes/sec] received 
    2626 
    2727Connection Times (ms) 
    2828              min  mean[+/-sd] median   max 
    29 Connect:        0    0   1.4      0       8 
    30 Processing:    39 1856 1942.1   1454   19325 
    31 Waiting:       38 1848 1943.3   1449   19324 
    32 Total:         39 1856 1942.3   1454   19327 
     29Connect:        0    0   1.3      0       8 
     30Processing:   151 1874 1367.8   1616   19484 
     31Waiting:      151 1861 1365.3   1611   19483 
     32Total:        151 1874 1367.9   1616   19485 
    3333 
    3434Percentage of the requests served within a certain time (ms) 
    35   50%   1454 
    36   66%   1487 
    37   75%   1563 
    38   80%   1701 
    39   90%   2193 
    40   95%   2901 
    41   98%   7020 
    42   99%  13180 
    43  100%  19327 (longest request) 
     35  50%   1616 
     36  66%   1647 
     37  75%   1692 
     38  80%   1743 
     39  90%   2172 
     40  95%   2907 
     41  98%   6538 
     42  99%   8099 
     43 100%  19485 (longest request) 
  • docs/hidek/bench/nanoa/lib/NanoA.pm

    r23380 r23406  
    3636        my $cgi_path = $cgi_klass; 
    3737        $cgi_path =~ s{::}{/}g; 
    38         require "$cgi_path.pm"; 
     38        require_once("$cgi_path.pm"); 
    3939        $self->{query} = $cgi_klass->new; 
    4040    } 
     
    7474    my $self = shift; 
    7575    my $headers = $self->{headers}; 
    76     my $ct = 
    77         delete($headers->{-type}) . "; charset=" . delete($headers->{-charset}); 
     76    my $ct = delete $headers->{-type}; 
     77    if ($ct =~ /;\s*charset=/) { 
     78        delete $headers->{-charset}; 
     79    } else { 
     80        $ct .= "; charset=" . delete $headers->{-charset}; 
     81    } 
    7882    print "Content-Type: $ct\n"; 
    7983    foreach my $n (sort keys %$headers) { 
     
    9195    print "\n"; 
    9296} 
    93      
     97 
     98my %REQUIRED; 
     99 
     100sub require_once { 
     101    my $path = shift; 
     102    return if $REQUIRED{$path}; 
     103    require $path; 
     104    $REQUIRED{$path} = 1; 
     105} 
     106 
     107my %LOADED; 
     108 
     109sub load_once { 
     110    my ($path, $mark_path) = @_; 
     111    $mark_path ||= $path; 
     112    return if $LOADED{$mark_path}; 
     113    local $@; 
     114    do "$path" 
     115        or return; 
     116    die $@ 
     117        if $@; 
     118    $LOADED{$mark_path} = 1; 
     119} 
     120 
     121sub loaded { 
     122    my $path = shift; 
     123    $LOADED{$path} = shift 
     124        if @_; 
     125    $LOADED{$path}; 
     126} 
     127 
    94128package NanoA::Dispatch; 
    95129 
     
    140174    $path =~ s{/+$}{}; 
    141175    local $@; 
    142     eval { 
    143         # should have a different invocation model for mod_perl and fastcgi 
    144         require "$path.pm"; 
    145     }; 
    146     unless ($@) { 
    147         my $module = $path; 
    148         $module =~ s{/}{::}g; 
    149         return $module; 
    150     } 
    151     return 
    152         if $@ =~ /^Can't locate /; 
    153     die $@; 
     176    NanoA::load_once("$path.pm") 
     177        or return; 
     178    my $module = $path; 
     179    $module =~ s{/}{::}g; 
     180    return $module; 
    154181} 
    155182 
     
    159186    return 
    160187        unless -e "$path.mt"; 
    161     NanoA::Mojo::Template->__load($config, $path); 
     188    NanoA::Mojo::Template::__load($config, $path); 
    162189} 
    163190 
     
    187214use base qw(NanoA); 
    188215 
    189 my %LOADED; 
    190  
    191216sub include { 
    192217    my ($app, $path) = @_; 
    193     my $module = $app->__load($app->config, $app->config->{prefix} . "/$path"); 
     218    my $module = __load($app->config, $app->config->{prefix} . "/$path"); 
    194219    $module->run_as($app); 
    195220} 
    196221 
    197222sub __load { 
    198     my ($self, $config, $path) = @_; 
     223    my ($config, $path) = @_; 
    199224    my $module = $path; 
    200225    $module =~ s{/}{::}g; 
    201226    return $module 
    202         if $LOADED{$path}; 
    203     if ($self->__use_cache($config, $path)) { 
    204         require "$config->{mt_cache_dir}/$path.mtc"; 
    205         $LOADED{$path} = 1; 
     227        if NanoA::loaded($path); 
     228    if (__use_cache($config, $path)) { 
     229        NanoA::load_once("$config->{mt_cache_dir}/$path.mtc", "$path.mt"); 
    206230        return $module; 
    207231    } 
    208     my $code = $self->__compile($path, $module); 
     232    my $code = __compile($path, $module); 
    209233    local $@; 
    210234    eval $code; 
    211235    die $@ if $@; 
    212     $self->__update_cache($config, $path, $code) 
     236    __update_cache($config, $path, $code) 
    213237        if $config->{mt_cache_dir}; 
    214     $LOADED{$path} = 1; 
     238    NanoA::loaded($path, 1); 
    215239    $module; 
    216240} 
    217241 
     242my $mt_loaded; 
     243 
    218244sub __compile { 
    219     my ($self, $path, $module) = @_; 
    220     __load_once("Mojo/Template.pm"); 
     245    my ($path, $module) = @_; 
     246    unless ($mt_loaded) { 
     247        NanoA::require_once("Mojo/Template.pm"); 
     248        $mt_loaded = 1; 
     249    } 
    221250    my $mt = Mojo::Template->new; 
    222251    $mt->parse(__read_file("$path.mt")); 
     
    241270} 
    242271 
    243 sub __load_once { 
    244     my $path = shift; 
    245     return if $LOADED{$path}; 
    246     require "$path"; 
    247 } 
    248  
    249272sub __update_cache { 
    250     my ($self, $config, $path, $code) = @_; 
     273    my ($config, $path, $code) = @_; 
    251274    my $cache_path = $config->{mt_cache_dir}; 
    252275    foreach my $p (split '/', $path) { 
     
    262285 
    263286sub __use_cache { 
    264     my ($self, $config, $path) = @_; 
     287    my ($config, $path) = @_; 
    265288    return unless $config->{mt_cache_dir}; 
    266289    my @orig = stat "$path.mt"