- Timestamp:
- 11/12/08 20:21:36 (5 years ago)
- Location:
- docs/hidek/bench/nanoa
- Files:
-
- 2 modified
-
benchmark.out (modified) (1 diff)
-
lib/NanoA.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
docs/hidek/bench/nanoa/benchmark.out
r23397 r23406 14 14 15 15 Concurrency Level: 100 16 Time taken for tests: 19. 393726seconds16 Time taken for tests: 19.531023 seconds 17 17 Complete requests: 1000 18 18 Failed requests: 0 19 19 Write errors: 0 20 Total transferred: 1 56720 bytes20 Total transferred: 142680 bytes 21 21 HTML transferred: 10000 bytes 22 Requests per second: 51. 56[#/sec] (mean)23 Time per request: 19 39.373[ms] (mean)24 Time per request: 19. 394[ms] (mean, across all concurrent requests)25 Transfer rate: 7. 89[Kbytes/sec] received22 Requests per second: 51.20 [#/sec] (mean) 23 Time per request: 1953.102 [ms] (mean) 24 Time per request: 19.531 [ms] (mean, across all concurrent requests) 25 Transfer rate: 7.12 [Kbytes/sec] received 26 26 27 27 Connection Times (ms) 28 28 min mean[+/-sd] median max 29 Connect: 0 0 1. 40 830 Processing: 39 1856 1942.1 1454 1932531 Waiting: 38 1848 1943.3 1449 1932432 Total: 39 1856 1942.3 1454 1932729 Connect: 0 0 1.3 0 8 30 Processing: 151 1874 1367.8 1616 19484 31 Waiting: 151 1861 1365.3 1611 19483 32 Total: 151 1874 1367.9 1616 19485 33 33 34 34 Percentage of the requests served within a certain time (ms) 35 50% 1 45436 66% 1 48737 75% 1 56338 80% 17 0139 90% 21 9340 95% 290 141 98% 702042 99% 1318043 100% 19 327(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 36 36 my $cgi_path = $cgi_klass; 37 37 $cgi_path =~ s{::}{/}g; 38 require "$cgi_path.pm";38 require_once("$cgi_path.pm"); 39 39 $self->{query} = $cgi_klass->new; 40 40 } … … 74 74 my $self = shift; 75 75 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 } 78 82 print "Content-Type: $ct\n"; 79 83 foreach my $n (sort keys %$headers) { … … 91 95 print "\n"; 92 96 } 93 97 98 my %REQUIRED; 99 100 sub require_once { 101 my $path = shift; 102 return if $REQUIRED{$path}; 103 require $path; 104 $REQUIRED{$path} = 1; 105 } 106 107 my %LOADED; 108 109 sub 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 121 sub loaded { 122 my $path = shift; 123 $LOADED{$path} = shift 124 if @_; 125 $LOADED{$path}; 126 } 127 94 128 package NanoA::Dispatch; 95 129 … … 140 174 $path =~ s{/+$}{}; 141 175 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; 154 181 } 155 182 … … 159 186 return 160 187 unless -e "$path.mt"; 161 NanoA::Mojo::Template ->__load($config, $path);188 NanoA::Mojo::Template::__load($config, $path); 162 189 } 163 190 … … 187 214 use base qw(NanoA); 188 215 189 my %LOADED;190 191 216 sub include { 192 217 my ($app, $path) = @_; 193 my $module = $app->__load($app->config, $app->config->{prefix} . "/$path");218 my $module = __load($app->config, $app->config->{prefix} . "/$path"); 194 219 $module->run_as($app); 195 220 } 196 221 197 222 sub __load { 198 my ($ self, $config, $path) = @_;223 my ($config, $path) = @_; 199 224 my $module = $path; 200 225 $module =~ s{/}{::}g; 201 226 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"); 206 230 return $module; 207 231 } 208 my $code = $self->__compile($path, $module);232 my $code = __compile($path, $module); 209 233 local $@; 210 234 eval $code; 211 235 die $@ if $@; 212 $self->__update_cache($config, $path, $code)236 __update_cache($config, $path, $code) 213 237 if $config->{mt_cache_dir}; 214 $LOADED{$path} = 1;238 NanoA::loaded($path, 1); 215 239 $module; 216 240 } 217 241 242 my $mt_loaded; 243 218 244 sub __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 } 221 250 my $mt = Mojo::Template->new; 222 251 $mt->parse(__read_file("$path.mt")); … … 241 270 } 242 271 243 sub __load_once {244 my $path = shift;245 return if $LOADED{$path};246 require "$path";247 }248 249 272 sub __update_cache { 250 my ($ self, $config, $path, $code) = @_;273 my ($config, $path, $code) = @_; 251 274 my $cache_path = $config->{mt_cache_dir}; 252 275 foreach my $p (split '/', $path) { … … 262 285 263 286 sub __use_cache { 264 my ($ self, $config, $path) = @_;287 my ($config, $path) = @_; 265 288 return unless $config->{mt_cache_dir}; 266 289 my @orig = stat "$path.mt"
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)