Skip to content

Commit

Permalink
renamed i function to n
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 10, 2014
1 parent 685fd14 commit bffa369
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -2,7 +2,7 @@
5.27 2014-08-11
- Added support for nested helpers.
- Added get_helper method to Mojolicious::Renderer.
- Added i function to ojo.
- Added n function to ojo.

5.26 2014-08-09
- Improved WebSocket performance.
Expand Down
22 changes: 11 additions & 11 deletions lib/ojo.pm
Expand Up @@ -30,8 +30,8 @@ sub import {
d => sub { _request($ua, 'DELETE', @_) },
g => sub { _request($ua, 'GET', @_) },
h => sub { _request($ua, 'HEAD', @_) },
i => sub (&@) { say STDERR timestr timeit($_[1] // 1, $_[0]) },
j => \&j,
n => sub (&@) { say STDERR timestr timeit($_[1] // 1, $_[0]) },
o => sub { _request($ua, 'OPTIONS', @_) },
p => sub { _request($ua, 'POST', @_) },
r => \&dumper,
Expand Down Expand Up @@ -136,16 +136,6 @@ L<Mojo::Message::Response> object.
Perform C<HEAD> request with L<Mojo::UserAgent/"head"> and return resulting
L<Mojo::Message::Response> object.
=head2 i
i {...};
i {...} 100;
Benchmark block and print the results to C<STDERR>, with an optional number of
iterations, which defaults to C<1>.
$ perl -Mojo -E 'i { say g("mojolicio.us")->code }'
=head2 j
my $bytes = j([1, 2, 3]);
Expand All @@ -156,6 +146,16 @@ Encode Perl data structure or decode JSON with L<Mojo::JSON/"j">.
$ perl -Mojo -E 'b(j({hello => "world!"}))->spurt("hello.json")'
=head2 n
n {...};
n {...} 100;
Benchmark block and print the results to C<STDERR>, with an optional number of
iterations, which defaults to C<1>.
$ perl -Mojo -E 'n { say g("mojolicio.us")->code }'
=head2 o
my $res = o('example.com');
Expand Down
4 changes: 2 additions & 2 deletions t/mojolicious/ojo.t
Expand Up @@ -55,10 +55,10 @@ is r([1, 2]), "[\n 1,\n 2\n]\n", 'right result';
open my $handle, '>', \$buffer;
local *STDERR = $handle;
my $i = 0;
i { ++$i };
n { ++$i };
is $i, 1, 'block has been invoked once';
like $buffer, qr/wallclock/, 'right output';
i { $i++ } 10;
n { $i++ } 10;
is $i, 11, 'block has been invoked ten times';
like $buffer, qr/wallclock.*wallclock/s, 'right output';
}
Expand Down

0 comments on commit bffa369

Please sign in to comment.