Skip to content

Commit

Permalink
1.28 - 2024-09-20
Browse files Browse the repository at this point in the history
Added commands: max, min (from List::Util).
Added limit to number of processes with runf (currently set to 20).
Updated pod.
  • Loading branch information
Timofey Potapov committed Sep 20, 2024
1 parent c74667d commit f541340
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Revision history for e

=================
1.28 - 2024-09-20
=================

Added commands: max, min (from List::Util).
Added limit to number of processes with runf (currently set to 20).
Updated pod.

=================
1.27 - 2024-08-08
=================
Expand Down
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
⠹⡽⣾⣿⠹⣿⣆⣾⢯⣿⣿ ⡞ ⠻⣿⣿⣿⠁ ⢠⣿⢏ ⡀ ⡟ ⢀⣴⣿⠃⢁⡼⠁ ⠈
⠈⠛ ⢻⣿⣧⢸⢟⠶⢾⡇ ⣸⡿⠁ ⢠⣾⡟⢼ ⣷ ⡇ ⣰⠋⠙⠁
⠈⣿⣻⣾⣦⣇⢸⣇⣀⣶⡿⠁⣀⣀⣾⢿⡇⢸ ⣟⡦⣧⣶⠏ unleashed
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.27
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.28
⢻⡄ ⠐⠚⠋⣠⡾⣧⣿⠁⠙⢳⣽⡟
⠈⠳⢦⣤⣤⣀⣤⡶⠛ ⠈⢿⡆ ⢿⡇
⠈ ⠈⠓ ⠈
Expand Down Expand Up @@ -153,7 +153,18 @@ Simple debugger on the command line:

Show a stack trace.

trace( $depth=1 )
trace( OPTIONS )

OPTIONS:

-levels => NUM, # How many scope levels to show.
NUM, # Same.

-raw => 1, # Include internal calls.
-NUM, # Same.

-message => STR, # Message to display.
STR, # Same.

### watch

Expand Down Expand Up @@ -203,6 +214,13 @@ Benchmark and compare different pieces of code.
fast => sub{ ... },
}, 10000;

$ perl -Me -e '$v = 333; n { concat => sub { 111 . $v }, interp => sub { "111$v" }, list => sub { 111,$v } }, 100000000'

Rate interp concat list
interp 55248619/s -- -6% -62%
concat 58479532/s 6% -- -60%
list 144927536/s 162% 148% --

## Format Conversions

### j
Expand Down Expand Up @@ -399,6 +417,22 @@ Turn string into a [Mojo::File](https://metacpan.org/pod/Mojo%3A%3AFile) object.

$ perl -Me -e 'say r j f("hello.json")->slurp'

## Math Help

### max

Get the biggest number in a list.

$ perl -Me -e 'say max 2,4,1,3'
4

### min

Get the smallest number in a list.

$ perl -Me -e 'say max 2,4,1,3'
1

## Output

### say
Expand Down Expand Up @@ -517,9 +551,13 @@ Turn a string into a [Mojo::URL](https://metacpan.org/pod/Mojo%3A%3AURL) object.
This sector includes commands to run asynchronous
(or pseudo-async) operations.

It is not exturely clear with method to always use.
It is not entirely clear which method to always use.

Typically using threads (with `runt`) is the fastest.
`runf` limits to number of action or 20 (whichever is smaller).

`runt` and `runio` have no such limits.

Typically using threads (with `runt`) seems to be fastest.

Some statistics using different run commands:

Expand Down Expand Up @@ -569,6 +607,8 @@ Returns the results.

Takes much overhead to start up!

Will use up to 20 processes.

### runio

Run tasks in parallel using [Mojo::IOLoop](https://metacpan.org/pod/Mojo%3A%3AIOLoop).
Expand Down
76 changes: 70 additions & 6 deletions lib/e.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package e;
⠹⡽⣾⣿⠹⣿⣆⣾⢯⣿⣿ ⡞ ⠻⣿⣿⣿⠁ ⢠⣿⢏ ⡀ ⡟ ⢀⣴⣿⠃⢁⡼⠁ ⠈
⠈⠛ ⢻⣿⣧⢸⢟⠶⢾⡇ ⣸⡿⠁ ⢠⣾⡟⢼ ⣷ ⡇ ⣰⠋⠙⠁
⠈⣿⣻⣾⣦⣇⢸⣇⣀⣶⡿⠁⣀⣀⣾⢿⡇⢸ ⣟⡦⣧⣶⠏ unleashed
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.27
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.28
⢻⡄ ⠐⠚⠋⣠⡾⣧⣿⠁⠙⢳⣽⡟
⠈⠳⢦⣤⣤⣀⣤⡶⠛ ⠈⢿⡆ ⢿⡇
⠈ ⠈⠓ ⠈
Expand All @@ -45,7 +45,7 @@ use 5.006;
use strict;
use warnings;

our $VERSION = '1.27';
our $VERSION = '1.28';

=head1 SYNOPSIS
Expand Down Expand Up @@ -171,7 +171,18 @@ Simple debugger on the command line:
Show a stack trace.
trace( $depth=1 )
trace( OPTIONS )
OPTIONS:
-levels => NUM, # How many scope levels to show.
NUM, # Same.
-raw => 1, # Include internal calls.
-NUM, # Same.
-message => STR, # Message to display.
STR, # Same.
=head3 watch
Expand Down Expand Up @@ -221,6 +232,13 @@ Benchmark and compare different pieces of code.
fast => sub{ ... },
}, 10000;
$ perl -Me -e '$v = 333; n { concat => sub { 111 . $v }, interp => sub { "111$v" }, list => sub { 111,$v } }, 100000000'
Rate interp concat list
interp 55248619/s -- -6% -62%
concat 58479532/s 6% -- -60%
list 144927536/s 162% 148% --
=cut

=head2 Format Conversions
Expand Down Expand Up @@ -427,6 +445,24 @@ Turn string into a L<Mojo::File> object.
=cut

=head2 Math Help
=head3 max
Get the biggest number in a list.
$ perl -Me -e 'say max 2,4,1,3'
4
=head3 min
Get the smallest number in a list.
$ perl -Me -e 'say max 2,4,1,3'
1
=cut

=head2 Output
=head3 say
Expand Down Expand Up @@ -549,9 +585,13 @@ Turn a string into a L<Mojo::URL> object.
This sector includes commands to run asynchronous
(or pseudo-async) operations.
It is not exturely clear with method to always use.
It is not entirely clear which method to always use.
Typically using threads (with C<runt>) is the fastest.
C<runf> limits to number of action or 20 (whichever is smaller).
C<runt> and C<runio> have no such limits.
Typically using threads (with C<runt>) seems to be fastest.
Some statistics using different run commands:
Expand Down Expand Up @@ -601,6 +641,8 @@ Returns the results.
Takes much overhead to start up!
Will use up to 20 processes.
=head3 runio
Run tasks in parallel using L<Mojo::IOLoop>.
Expand Down Expand Up @@ -913,6 +955,26 @@ sub import {
Mojo::File::path( @_ );
},

######################################
# Math Help
######################################

max => sub {
if ( !$imported{$caller}{"List::Util"}++ ) {
require List::Util;
}

List::Util::max( @_ );
},

min => sub {
if ( !$imported{$caller}{"List::Util"}++ ) {
require List::Util;
}

List::Util::min( @_ );
},

######################################
# Output
######################################
Expand Down Expand Up @@ -1072,7 +1134,9 @@ sub import {
require Parallel::ForkManager;
}

my $pm = Parallel::ForkManager->new( ~~ @_ );
my $MAX_PROCESSES = 20;
my $processes = ( @_ > $MAX_PROCESSES ) ? $MAX_PROCESSES : @_;
my $pm = Parallel::ForkManager->new( $processes );
my @res;

$pm->run_on_finish(
Expand Down
14 changes: 14 additions & 0 deletions t/01-simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ is
"cpuinfo",
"f - basename";

######################################
# Math Help
######################################

is
max(10,20,9,15),
20,
"max - sanity check";

is
min(10,20,9,15),
9,
"min - sanity check";

######################################
# Output
######################################
Expand Down

0 comments on commit f541340

Please sign in to comment.