view release on metacpan or search on metacpan
examples/refactor_until_clean.pl view on Meta::CPAN
# Create event loop
my $loop = IO::Async::Loop->new;
# Configure refactor options
my $options = Claude::Agent::Code::Refactor::Options->new(
max_iterations => 5, # Max review-fix cycles
min_severity => 'medium', # Only fix medium+ issues
categories => ['bugs', 'security'], # Focus on these
permission_mode => 'acceptEdits', # Auto-accept file edits
perlcritic => 1, # Include perlcritic analysis
perlcritic_severity => 4, # Perlcritic severity level
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Claude/Agent/Code/Review.pm view on Meta::CPAN
loop => $loop,
);
# Collect result asynchronously with iteration limit
my $result;
my $max_iterations = 1000; # Prevent infinite loops
my $iterations = 0;
while (my $msg = await $iter->next_async) {
$iterations++;
if ($msg->isa('Claude::Agent::Message::Result')) {
$result = $msg;
last;
}
if ($iterations >= $max_iterations) {
$iter->cleanup(); # Cleanup SDK server sockets
return Claude::Agent::Code::Review::Report->new(
summary => 'Review timed out: exceeded maximum iterations',
issues => [],
);
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Claude/Agent/Client.pm view on Meta::CPAN
# MEMORY WARNING: Each message object may be 1-100KB depending on content.
# At max (5000 messages), memory usage could reach 50MB-500MB.
# For long-running operations, consider processing messages incrementally
# using receive() in a loop rather than receive_until_result().
# Set CLAUDE_AGENT_MAX_MEMORY_MB to limit memory usage (default 500MB).
my $max_iterations = 1000;
my $max_allowed = 5_000; # Reduced to prevent memory exhaustion (each message ~1-100KB)
my $max_msg_env = $ENV{CLAUDE_AGENT_MAX_MESSAGES};
$max_msg_env =~ s/^\s+|\s+$//g if defined $max_msg_env; # trim whitespace
# Validate after trimming - must be positive integer > 0 (rejects 0 and leading zeros)
if (defined $max_msg_env && $max_msg_env =~ /^[1-9]\d*$/) {
$max_iterations = $max_msg_env;
if ($max_iterations > $max_allowed) {
$log->warning(sprintf("CLAUDE_AGENT_MAX_MESSAGES=%d exceeds maximum (%d), using %d. "
. "WARNING: High message counts risk memory exhaustion (estimated %dMB-%dMB at max). "
. "Set CLAUDE_AGENT_MAX_MEMORY_MB to limit memory, or use receive() for incremental processing.",
$max_iterations, $max_allowed, $max_allowed, $max_allowed / 10, $max_allowed / 1));
$max_iterations = $max_allowed;
}
elsif ($max_iterations > 2500) {
$log->warning(sprintf("CLAUDE_AGENT_MAX_MESSAGES=%d may cause high memory usage (estimated %dMB-%dMB). "
. "Consider using receive() with incremental processing or set CLAUDE_AGENT_MAX_MEMORY_MB.",
$max_iterations, $max_iterations / 10, $max_iterations / 1));
}
}
my $iterations = 0;
# Create JSON::Lines instance once outside the loop for better performance
require JSON::Lines;
my $jsonl = JSON::Lines->new;
while (my $msg = $self->receive) {
$iterations++;
push @messages, $msg;
# Estimate memory usage (rough heuristic based on message content)
# Estimate size based on raw data structure - use JSON::Lines for encoding
my $json_str = eval { $jsonl->encode([$msg->message // {}]) } // '{}';
$estimated_memory += length($json_str) + 500; # Add overhead estimate
lib/Claude/Agent/Client.pm view on Meta::CPAN
$log->warning(sprintf("receive_until_result: estimated memory usage (%d bytes) exceeds limit (%d bytes), breaking loop. "
. "Set CLAUDE_AGENT_MAX_MEMORY_MB to increase limit or use incremental processing.",
$estimated_memory, $max_memory_bytes));
last;
}
if ($iterations >= $max_iterations) {
$log->warning(sprintf("receive_until_result: processed max messages (%d), breaking loop. "
. "Set CLAUDE_AGENT_MAX_MESSAGES to increase limit.", $max_iterations));
last;
}
}
# Check if we exited without a Result (connection dropped)
if (@messages && !$messages[-1]->isa('Claude::Agent::Message::Result')) {
view all matches for this distribution
view release on metacpan or search on metacpan
bench/complex_insert_benchmark.pl view on Meta::CPAN
optional Nullable(UInt64)
) engine = Null'");
# Benchmark function
sub bench_insert {
my ($format, $data, $iterations) = @_;
my @times;
for my $i (1 .. $iterations) {
my $t0 = time();
open my $fh, '|-', "clickhouse-client --port $PORT --query 'insert into bench_complex format $format' 2>/dev/null"
or die "Cannot run clickhouse-client: $!";
binmode $fh;
print $fh $data;
view all matches for this distribution
view release on metacpan or search on metacpan
t/12-memleak.t view on Meta::CPAN
clone($tmp);
}
my $after = get_rss_kb();
my $delta = $after - $before;
ok($delta < 2000, "clone via intermediate variable does not leak (delta: ${delta} KB)")
or diag("Memory grew by $delta KB over 100K iterations");
}
}
# Test 5: direct hash miss should not leak (the actual bug from GH #42)
{
t/12-memleak.t view on Meta::CPAN
Clone::clone($data->{no_such_key});
}
my $after = get_rss_kb();
my $delta = $after - $before;
ok($delta < 2000, "clone of hash miss does not leak (delta: ${delta} KB)")
or diag("Memory grew by $delta KB over 100K iterations â GH #42 regression");
}
}
# Test 6: populated hash, direct miss should not leak
{
t/12-memleak.t view on Meta::CPAN
Clone::clone($hash{nonexistent});
}
my $after = get_rss_kb();
my $delta = $after - $before;
ok($delta < 2000, "clone of hash miss on populated hash does not leak (delta: ${delta} KB)")
or diag("Memory grew by $delta KB over 100K iterations");
}
}
# Test 7: clone of existing hash key should work fine and not leak
{
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-b
-bar
-boc
-ci=4
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-bar
-boc
-ci=4
-i=4
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-b
-bar
-boc
-ci=4
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-b
-bar
-boc
-ci=4
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-b
-bar
-boc
-ci=4
view all matches for this distribution
view release on metacpan or search on metacpan
-npro
-nsfs
--blank-lines-before-packages=0
--opening-hash-brace-right
--no-outdent-long-comments
--iterations=2
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
view all matches for this distribution
view release on metacpan or search on metacpan
--blank-lines-before-packages=0
--iterations=2
--no-outdent-long-comments
-b
-bar
-boc
-ci=4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Code/TidyAll.pm view on Meta::CPAN
is => 'lazy',
isa => t('Path'),
coerce => t('Path')->coercion_sub,
);
has iterations => (
is => 'ro',
isa => t('PositiveInt'),
default => 1,
);
lib/Code/TidyAll.pm view on Meta::CPAN
This affects both loading and running plugins.
=item * data_dir
=item * iterations
=item * mode
=item * no_backups
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Colouring/In/XS.pm view on Meta::CPAN
}
});
...
Benchmark: timing 1000000 iterations of Colouring::In, XS...
Colouring::In: 13 wallclock secs (12.36 usr + 0.00 sys = 12.36 CPU) @ 80906.15/s (n=1000000)
XS: 0 wallclock secs ( 0.59 usr + 0.01 sys = 0.60 CPU) @ 1666666.67/s (n=1000000)
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Command/Run.pm view on Meta::CPAN
than fork in either mode, and most of the historical gap between
C<:encoding> and raw mode (which was caused by the accumulation) is
gone:
# Benchmark: code ref with stdin (100-byte input,
# 1000 iterations, object reused)
fork: 495/s (baseline)
nofork + :encoding: 15,997/s (32x)
nofork + :utf8 (raw): 20,038/s (40x)
=head2 Zero-Modification Callee Integration
view all matches for this distribution
view release on metacpan or search on metacpan
7zip/DOC/lzma.txt view on Meta::CPAN
instructions per second). Rating value is calculated from
measured speed and it is normalized with Intel's Core 2 results.
Also Benchmark checks possible hardware errors (RAM
errors in most cases). Benchmark uses these settings:
(-a1, -d21, -fb32, -mfbt4). You can change only -d parameter.
Also you can change the number of iterations. Example for 30 iterations:
LZMA b 30
Default number of iterations is 10.
<Switches>
-a{N}: set compression mode 0 = fast, 1 = normal
view all matches for this distribution
view release on metacpan or search on metacpan
ex/benchmark.pl view on Meta::CPAN
use Compress::LZF ();
use Compress::Snappy ();
use Compress::Zlib ();
my %opts = (
iterations => -1,
size => 10, # kB
);
GetOptions(\%opts, 'iterations|i=i', 'size|s=f',);
my $data = join '', ('A'..'Z', 'a'..'z', 0..9, qw(_ .)) x (16 * $opts{size});
my %compress = (
'Compress::Bzip2::compress' => sub { Compress::Bzip2::compress($data) },
view all matches for this distribution
view release on metacpan or search on metacpan
ex/benchmark.pl view on Meta::CPAN
use Compress::LZF ();
use Compress::Snappy ();
use Compress::Zlib ();
my %opts = (
iterations => -1,
size => 10, # kB
);
GetOptions(\%opts, 'iterations|i=i', 'size|s=f',);
my $data = join '', ('A'..'Z', 'a'..'z', 0..9, qw(_ .)) x (16 * $opts{size});
my %compress = (
'Compress::Bzip2::compress' => sub { Compress::Bzip2::compress($data) },
view all matches for this distribution
view release on metacpan or search on metacpan
ext/zstd/CONTRIBUTING.md view on Meta::CPAN
increase your sample count. These should get smaller and smaller. Eventually hopefully
smaller than the performance win you are expecting.
* Most processors will take some time to get `hot` when running anything. The observations
you collect during that time period will very different from the true performance number. Having
a very large number of sample will help alleviate this problem slightly but you can also
address is directly by simply not including the first `n` iterations of your benchmark in
your aggregations. You can determine `n` by simply looking at the results from each iteration
and then hand picking a good threshold after which the variance in results seems to stabilize.
2. You cannot really get reliable benchmarks if your host machine is simultaneously running
another cpu/memory-intensive application in the background. If you are running benchmarks on your
personal laptop for instance, you should close all applications (including your code editor and
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Compress/Zopfli.pm view on Meta::CPAN
=head1 SYNOPSIS
use Compress::Zopfli;
$gz = compress($input, ZOPFLI_FORMAT_GZIP, {
iterations => 15,
blocksplitting => 1,
blocksplittingmax => 15,
});
=head1 DESCRIPTION
lib/Compress/Zopfli.pm view on Meta::CPAN
Options map directly to the I<zopfli> low-level function. Must be a hash
reference (i.e. anonymous hash) and supports the following options:
=over 5
=item B<iterations>
Maximum amount of times to rerun forward and backward pass to optimize LZ77
compression cost. Good values: 10, 15 for small files, 5 for files over
several MB in size or it will be too slow. Default: 15
lib/Compress/Zopfli.pm view on Meta::CPAN
- I<Compress::Zopfli::Deflate>
They export one B<compress> function without the I<ZOPFLI_FORMAT> option.
use Compress::Zopfli::Deflate;
compress $input, { iterations: 20 };
=head1 CONSTANTS
All the I<zopfli> constants are automatically imported when you make use
of I<Compress::Zopfli>. See L</DESCRIPTION> for a complete list.
view all matches for this distribution
view release on metacpan or search on metacpan
ext/zstd/lib/compress/zstd_ldm.c view on Meta::CPAN
/* 3. Generate the sequences for the chunk, and get newLeftoverSize. */
newLeftoverSize = ZSTD_ldm_generateSequences_internal(
ldmState, sequences, params, chunkStart, chunkSize);
if (ZSTD_isError(newLeftoverSize))
return newLeftoverSize;
/* 4. We add the leftover literals from previous iterations to the first
* newly generated sequence, or add the `newLeftoverSize` if none are
* generated.
*/
/* Prepend the leftover literals from the last call */
if (prevSize < sequences->size) {
view all matches for this distribution
view release on metacpan or search on metacpan
t/mutant_killers.t view on Meta::CPAN
my $cfg = Config::Abstraction->new(
config_dirs => [$dir1, $dir2],
);
ok(defined($cfg), 'object created with multiple dirs');
# Both dirs loaded; script_name consistent across both iterations
is($cfg->get('dir1key'), 'dir1val', 'dir1 loaded correctly');
is($cfg->get('dir2key'), 'dir2val', 'dir2 loaded correctly');
ok(defined($cfg->{script_name}), 'script_name was set');
};
view all matches for this distribution
view release on metacpan or search on metacpan
use Test::More qw(no_plan);
# run this with the call to weaken() in ApacheFormat.pm commented out
# and watch the amazing leaking code in top! You might need to add
# more iterations if it's buzzing by too fast.
for(0 .. 100) {
my $config = Config::ApacheFormat->new();
$config->read("t/block.conf");
ok(1);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Config/YAMLMacros.pm view on Meta::CPAN
our @ISA = qw(Exporter);
our @EXPORT = qw(get_config);
our @EXPORT_OK = (@EXPORT, qw(listify replace));
my $max_replace_iterations = 10;
sub listify(\%@)
{
my ($href, @keys) = @_;
for my $k (@keys) {
lib/Config/YAMLMacros.pm view on Meta::CPAN
# print STDERR "# replacing '$_[0]' with '$href->{$_[0]}'\n";
return $href->{$_[0]};
};
for (;;) {
$$sref =~ s/($re)/$replace->($1)/ge or last;
if ($iteration++ >= $max_replace_iterations) {
confess "too many replacements in $$sref";
}
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
libucl-0.8.1/doc/api.md view on Meta::CPAN
If parsing operations fail then the resulting UCL object will be a `UCL_STRING`. A caller should always check the type of the returned object and release it after using.
# Iteration functions
Iteration are used to iterate over UCL compound types: arrays and objects. Moreover, iterations could be performed over the keys with multiple values (implicit arrays).
There are two types of iterators API: old and unsafe one via `ucl_iterate_object` and the proposed interface of safe iterators.
## ucl_iterate_object
~~~C
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
If terms and precision is not given, both are estimated from the given number of
places. This will result in a value of Pi, which is accurate to the requested
places. If places, terms and/or precision is given, the behaviour of the algorithm
can be studied with respect to terms and/or precision.
The number of iterations is calculated using the knowledge, that each iteration
should result in e.g. 14 new digits after the decimal point. So the value for the
calculation of the number of terms is set to e.g. 14. To make sure that reverse as
less as possible digits are changed, the number of terms to calculated is uneven.
So the sign of the term to add is negative after the decimal point.
lib/ConstantCalculus/CircleConstant.pm view on Meta::CPAN
is exponentiated by e (exponent) and divided by a positive integer m
(modulus).
=head3 estimate_terms()
Estimates the terms or iterations to get the correct number of place.
=head3 truncate_places()
Truncate the number of places to a given value.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Container/Buildah.pm view on Meta::CPAN
# process scalar value
my $output;
$cb->{template}->process(\$value, $cb->{config}, \$output);
$cb->debug({level => 4}, "expand: $value -> $output");
# expand templates as long as any remain, up to 10 iterations
my $count=0;
while ($output =~ / \[% .* %\] /x and $count++ < 10) {
$value = $output;
$output = ""; # clear because template concatenates to it
$cb->{template}->process(\$value, $cb->{config}, \$output);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ControlBreak.pm view on Meta::CPAN
our $VERSION = 'v0.22.244';
use Carp qw(croak);
# public attributes
field $iteration :reader { 0 }; # [0] counts iterations
field @level_names :reader; # [1] list of level names
# private attributes
field $_num_levels; # [2] the number of control levels
field %_levname { }; # [3] map of levidx to levname
lib/ControlBreak.pm view on Meta::CPAN
A readonly field that provides the current iteration number.
This can be useful if you are doing an final processing after an
iteration loop has ended. In the event that the data stream is empty
and there were no iterations, then you can condition your final
processing on iteration > 0.
Note that the B<interation> field is incremented by B<test()> (or
B<test_and_do()>). Therefore, when called within a loop it is
effectively zero-based if referenced within the iteration block
lib/ControlBreak.pm view on Meta::CPAN
}
=head2 reset
Resets the state of the object so it can be used again for another
set of iterations using the same number and type of controls
establish when the object was instantiated with B<new()>. Any
comparisons that were subsequently modified are retained.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
tests/601_speed.t view on Meta::CPAN
-e $cache and unlink $cache;
# check "normal" C::B::C object
$tests = 5;
$next_test_time = 0;
$iterations = 0;
$start_time = mytime();
$elapsed_time = 0;
$fail = 0;
while ($elapsed_time < $required_time) {
eval {
$c = Convert::Binary::C->new( %$CCCFG );
$c->parse_file( 'tests/include/include.c' );
};
$@ and $fail = 1 and last;
$iterations++;
$elapsed_time = mytime() - $start_time;
# this is just to prevent the user from stopping the test
if( $elapsed_time >= $next_test_time and $tests > 0 ) {
$tests--;
tests/601_speed.t view on Meta::CPAN
ok(1) while $tests-- > 0;
ok( $fail, 0, "failed to perform reference speed test ($@)" );
print "# uncached: $iterations iterations in $elapsed_time seconds\n";
# create cache file
eval {
$c = Convert::Binary::C::Cached->new( Cache => $cache, %$CCCFG );
tests/601_speed.t view on Meta::CPAN
ok( -e $cache );
# check cached object (this should be a lot faster)
$start_time = mytime();
eval {
for( 1 .. $iterations ) {
$c = Convert::Binary::C::Cached->new( Cache => $cache, %$CCCFG );
$c->parse_file( 'tests/include/include.c' );
}
};
ok( $@, '', "failed to perform cached speed test ($@)" );
$cached_time = mytime() - $start_time;
$speedup = $cached_time < 0.001 ? 1000 : $elapsed_time / $cached_time;
print "# cached: $iterations iterations in $cached_time seconds\n";
print "# speedup is $speedup\n";
# a speedup of 2 is acceptable
ok( $speedup > 2 );
view all matches for this distribution