Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 5, 2013
1 parent cdf487a commit 692b400
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

3.98 2013-05-05
3.98 2013-05-06
- Added is_empty method to Mojo::Transaction::HTTP.
- Added close_gracefully method to Mojo::IOLoop::Stream.
- Removed deprecated build_form_tx, build_json_tx, post_form and post_json
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -109,7 +109,7 @@ sub dispatch {

# Prepare transaction
my $tx = $c->tx;
$c->res->code(undef) if $tx->is_websocket;
$tx->res->code(undef) if $tx->is_websocket;
$self->sessions->load($c);
my $plugins = $self->plugins->emit_hook(before_dispatch => $c);

Expand Down
9 changes: 5 additions & 4 deletions lib/Mojolicious/Plugin/RequestTimer.pm
Expand Up @@ -14,10 +14,10 @@ sub _end {

# Ignore static files
my $stash = $self->stash;
return unless my $started = delete $stash->{'mojo.started'};
return if $stash->{'mojo.static'};
my $elapsed = sprintf '%f',
Time::HiRes::tv_interval($started, [Time::HiRes::gettimeofday()]);

return unless my $started = delete $stash->{'mojo.started'};
my $elapsed = sprintf '%f', tv_interval($started, [gettimeofday]);
my $rps = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed;
my $res = $self->res;
my $code = $res->code || 200;
Expand All @@ -31,12 +31,13 @@ sub _start {
# Ignore static files
my $stash = $self->stash;
return if $stash->{'mojo.static'} || $stash->{'mojo.started'};

my $req = $self->req;
my $method = $req->method;
my $path = $req->url->path->to_abs_string;
my $ua = $req->headers->user_agent || 'Anonymojo';
$self->app->log->debug("$method $path ($ua).");
$stash->{'mojo.started'} = [Time::HiRes::gettimeofday()];
$stash->{'mojo.started'} = [gettimeofday];
}

1;
Expand Down

0 comments on commit 692b400

Please sign in to comment.