Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show some examples for how to use the profile->* helpers
  • Loading branch information
kraih committed Feb 10, 2018
1 parent 1e5b53b commit 972cfc0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/Mojo/Headers.pm
Expand Up @@ -614,7 +614,8 @@ Get or replace current header value, shortcut for the C<Server> header.
my $timing = $headers->server_timing;
$headers = $headers->server_timing('app;desc=Mojolicious;dur=0.0001');
Get or replace current header value, shortcut for the C<Server-Timing> header.
Get or replace current header value, shortcut for the C<Server-Timing> header
from L<Server Timing|https://www.w3.org/TR/server-timing/>.
Note that this method is EXPERIMENTAL and might change without warning!
=head2 set_cookie
Expand Down
15 changes: 13 additions & 2 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -487,12 +487,18 @@ Alias for L<Mojolicious::Controller/"stash">.
=head2 profile->elapsed
my $elapsed = $c->timer->elapsed('foo');
my $elapsed = $c->profile->elapsed('foo');
Return fractional number of seconds since named timstamp has been created with
L</"profile-E<gt>start"> or C<undef> if no such timestamp exists. Note that this
helper is EXPERIMENTAL and might change without warning!
# Log profiling information
$c->profile->start('database_stuff');
...
my $elapsed = $c->profile->elapsed('database_stuff');
$c->app->log->debug("Database stuff took $elapsed seconds");
=head2 profile->server_timing
$c->profile->server_timing('app');
Expand All @@ -501,7 +507,12 @@ helper is EXPERIMENTAL and might change without warning!
Create C<Server-Timing> header with or without named timestamp created with
L</"profile-E<gt>start">. Note that this helper is EXPERIMENTAL and might change
without warning!
without warning!
# Forward profiling information to browser
$c->profile->start('database_stuff');
...
$c->profile->server_timing('db', 'Database Stuff', 'database_stuff');
=head2 profile->start
Expand Down

0 comments on commit 972cfc0

Please sign in to comment.