view release on metacpan or search on metacpan
lib/Benchmark/Dumb.pm view on Meta::CPAN
benchmark should be run exactly C<$count> times. A negative value
indicated that the code should be run until C<$count> seconds of
cumulated run-time have elapsed.
With C<Benchmark::Dumb>, we can do better. A positive integer
specifies the I<minimum> number of iterations. C<Dumbbench> may choose
to run more iterations to arrive at the necessary precision.
Specifying a certain target run-time (via a negative number for C<$count>)
may seem like a tempting idea, but if you care at all about the precision
of your result, it's quite useless.
B<This usage is not supported by C<Benchmark::Dumb>!>
lib/Benchmark/Dumb.pm view on Meta::CPAN
I'm quoting the C<Benchmark> documentation liberally.
=head2 timethis(COUNT, CODE, [TITLE, [STYLE]])
Time I<COUNT> iterations of I<CODE>. I<CODE> may be a string to eval
or a code reference. Unlike with the original C<Benchmark>,
the code will B<not> run in the caller's package. Results will be printed
to C<STDOUT> as I<TITLE> followed by the C<timestr()>.
I<TITLE> defaults to C<"timethis COUNT"> if none is provided.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DynGig/Automata/Sequence.pm view on Meta::CPAN
};
=head1 MODE
In I<serial> mode, I<target> code must have an exhaustive batching behavior.
e.g. n targets T1 .. Tn into k batches in k iterations of I<target> code
ITERATION TARGET
========= ======
1 T1, T2 .. Tm
2 Tm+1 ..
view all matches for this distribution
view release on metacpan or search on metacpan
lib/DynGig/Util/CLI.pm view on Meta::CPAN
my %o = ( s => 30, link => 'current' );
my $menu = DynGig::Util::CLI->new
(
'h|help',"print help menu",
's|sleep=i',"[ $o{s} ] seconds between iterations",
'link=s',"[ $o{link} ] symlink to current config",
'server=s','server host:port',
);
my @option = $menu->option();
view all matches for this distribution
view release on metacpan or search on metacpan
Version 0.05, 2004-01-19
========================
- minor adjustments to POD documentation
- improve error messages generated by ecs_proc_meta script
- limit number of iterations through email inbox performed by scan_mail()
subroutine of ecs_scan_mail script
Version 0.06, 2004-03-02
========================
- ecstool: modify --meta option, adding capability to generate a series of
view all matches for this distribution
view release on metacpan or search on metacpan
web/javascript/unittest.js view on Meta::CPAN
}.bind(this)) && this.pass();
},
assertElementMatches: function(element, expression) {
this.assertElementsMatch([element], expression);
},
benchmark: function(operation, iterations) {
var startAt = new Date();
(iterations || 1).times(operation);
var timeTaken = ((new Date())-startAt);
this.info((arguments[2] || 'Operation') + ' finished ' +
iterations + ' iterations in ' + (timeTaken/1000)+'s' );
return timeTaken;
},
_isVisible: function(element) {
element = $(element);
if(!element.parentNode) return true;
web/javascript/unittest.js view on Meta::CPAN
this.assert(!this._isVisible(element), Test.Unit.inspect(element) + " was not hidden and didn't have a hidden parent either. " + ("" || arguments[1]));
},
assertVisible: function(element) {
this.assert(this._isVisible(element), Test.Unit.inspect(element) + " was not visible. " + ("" || arguments[1]));
},
benchmark: function(operation, iterations) {
var startAt = new Date();
(iterations || 1).times(operation);
var timeTaken = ((new Date())-startAt);
this.info((arguments[2] || 'Operation') + ' finished ' +
iterations + ' iterations in ' + (timeTaken/1000)+'s' );
return timeTaken;
}
};
Test.Unit.Testcase = Class.create();
view all matches for this distribution
view release on metacpan or search on metacpan
my $client = EV::Etcd->new(
endpoints => ['127.0.0.1:2379'],
);
my $prefix = "/bench_$$";
my $iterations = $ENV{BENCH_ITER} || 1000;
print "EV::Etcd Benchmark\n";
print "==================\n\n";
# Benchmark 1: Sequential puts
{
print "1. Sequential PUTs ($iterations iterations)...\n";
my $completed = 0;
my $start = time();
for my $i (1..$iterations) {
$client->put("$prefix/key$i", "value$i", sub {
my ($resp, $err) = @_;
die "PUT error: $err->{message}" if $err;
$completed++;
EV::break;
EV::run;
}
my $elapsed = time() - $start;
printf " Time: %.3f sec, Rate: %.0f ops/sec, Latency: %.2f ms/op\n\n",
$elapsed, $iterations / $elapsed, ($elapsed / $iterations) * 1000;
}
# Benchmark 2: Sequential gets
{
print "2. Sequential GETs ($iterations iterations)...\n";
my $completed = 0;
my $start = time();
for my $i (1..$iterations) {
$client->get("$prefix/key$i", sub {
my ($resp, $err) = @_;
die "GET error: $err->{message}" if $err;
$completed++;
EV::break;
EV::run;
}
my $elapsed = time() - $start;
printf " Time: %.3f sec, Rate: %.0f ops/sec, Latency: %.2f ms/op\n\n",
$elapsed, $iterations / $elapsed, ($elapsed / $iterations) * 1000;
}
# Benchmark 3: Pipelined puts (bounded concurrency)
{
my $concurrency = $ENV{BENCH_CONCURRENCY} || 100;
print "3. Pipelined PUTs ($iterations iterations, concurrency=$concurrency)...\n";
my $completed = 0;
my $sent = 0;
my $in_flight = 0;
my $start = time();
my $send_batch; $send_batch = sub {
while ($sent < $iterations && $in_flight < $concurrency) {
$sent++;
$in_flight++;
my $i = $sent;
$client->put("$prefix/pipe$i", "value$i", sub {
my ($resp, $err) = @_;
die "PUT error: $err->{message}" if $err;
$completed++;
$in_flight--;
if ($completed == $iterations) {
EV::break;
} else {
$send_batch->();
}
});
$send_batch->();
EV::run;
my $elapsed = time() - $start;
printf " Time: %.3f sec, Rate: %.0f ops/sec, Latency: %.2f ms/op\n\n",
$elapsed, $iterations / $elapsed, ($elapsed / $iterations) * 1000;
}
# Benchmark 4: Pipelined gets (bounded concurrency)
{
my $concurrency = $ENV{BENCH_CONCURRENCY} || 100;
print "4. Pipelined GETs ($iterations iterations, concurrency=$concurrency)...\n";
my $completed = 0;
my $sent = 0;
my $in_flight = 0;
my $start = time();
my $send_batch; $send_batch = sub {
while ($sent < $iterations && $in_flight < $concurrency) {
$sent++;
$in_flight++;
my $i = $sent;
$client->get("$prefix/pipe$i", sub {
my ($resp, $err) = @_;
die "GET error: $err->{message}" if $err;
$completed++;
$in_flight--;
if ($completed == $iterations) {
EV::break;
} else {
$send_batch->();
}
});
$send_batch->();
EV::run;
my $elapsed = time() - $start;
printf " Time: %.3f sec, Rate: %.0f ops/sec, Latency: %.2f ms/op\n\n",
$elapsed, $iterations / $elapsed, ($elapsed / $iterations) * 1000;
}
# Benchmark 5: Watch latency
{
print "5. Watch event latency (100 events)...\n";
view all matches for this distribution
view release on metacpan or search on metacpan
bench/benchmark.pl view on Meta::CPAN
my $end = time;
my $elapsed = $end - $start;
printf "%-30s: %8.4fs (%10.2f/s)\n", $name, $elapsed, $ITERATIONS / $elapsed;
}
print "Benchmarking $COUNT synchronous tasks over $ITERATIONS iterations:\n";
run_bench('EV::Future::parallel', sub {
EV::Future::parallel(\@tasks, sub { });
});
view all matches for this distribution
view release on metacpan or search on metacpan
src/EV__Kafka.xs view on Meta::CPAN
}
#ifdef HAVE_OPENSSL
/* SCRAM multi-step handling */
if (self->sasl_mechanism && self->scram_step == SCRAM_STEP_CLIENT_FIRST && auth_data) {
/* Server-first-message: r=<nonce>,s=<salt>,i=<iterations> */
/* Parse server response, compute proof, send client-final */
const char *server_nonce = NULL;
size_t server_nonce_len = 0;
const char *salt_b64 = NULL;
size_t salt_b64_len = 0;
int iterations = 0;
{
const char *sp = auth_data;
const char *se = auth_data + auth_data_len;
while (sp < se) {
if (sp + 2 <= se && sp[0] == 'r' && sp[1] == '=') {
src/EV__Kafka.xs view on Meta::CPAN
sp += 2; salt_b64 = sp;
while (sp < se && *sp != ',') sp++;
salt_b64_len = sp - salt_b64;
} else if (sp + 2 <= se && sp[0] == 'i' && sp[1] == '=') {
sp += 2;
iterations = atoi(sp);
while (sp < se && *sp != ',') sp++;
}
if (sp < se && *sp == ',') sp++;
else sp++;
}
}
if (!server_nonce || !salt_b64 || iterations <= 0) {
conn_emit_error(aTHX_ self, "SCRAM: malformed server-first-message");
if (conn_check_destroyed(self)) return;
conn_handle_disconnect(aTHX_ self, "SCRAM auth failed");
return;
}
src/EV__Kafka.xs view on Meta::CPAN
conn_handle_disconnect(aTHX_ self, "SCRAM auth failed");
return;
}
}
/* SaltedPassword = Hi(password, salt, iterations) using PBKDF2 */
unsigned char salted_password[64];
PKCS5_PBKDF2_HMAC(self->sasl_password, strlen(self->sasl_password),
salt, salt_len, iterations, md, digest_len, salted_password);
/* ClientKey = HMAC(SaltedPassword, "Client Key") */
unsigned char client_key[64];
unsigned int ck_len = digest_len;
HMAC(md, salted_password, digest_len,
view all matches for this distribution
view release on metacpan or search on metacpan
value of C<1> means that, after handling the pending events, it will call
C<< $loop->loop (EV::LOOP_NONBLOCK) >> and handle the resulting events, if
any. A value of C<2> means that this will be iterated twice.
When a foreground event poll does not yield any new events, then no
further iterations will be made, so this is only a I<maximum> value of
additional loop runs.
Take also note of the standard EV C<set_io_collect_interval>
functionality, which can achieve a similar, but different, effect - YMMV.
view all matches for this distribution
view release on metacpan or search on metacpan
- Fix escape, query_stream, stmt lifecycle, state caching
- Benchmark fixes and EV::Future integration
0.02 2026-03-15
- Fix: clear $@ (ERRSV) after G_EVAL callbacks to prevent pollution
across async event loop iterations
- Fix: query_stream on non-SELECT (DML) now delivers EOF instead of
a false error
- Fix: copy error string in stream_error before invoking callback
- Add fork detection via PID check at all operation entry points
- Add CLONE_SKIP to prevent unsafe ithread cloning
view all matches for this distribution
view release on metacpan or search on metacpan
t/flow_control.t view on Meta::CPAN
is $results[1][2], 'disconnected', 'cmd2 got disconnect error';
$r->max_pending(0);
}
# Edge case: reconnect after disconnect (separate event loop iterations)
{
$r->connect_unix( $connect_info{sock} );
my @results;
view all matches for this distribution
view release on metacpan or search on metacpan
bench/latency.pl view on Meta::CPAN
use EV::Websockets;
use Time::HiRes qw(time);
# Benchmark: Latency (Connection + Handshake time)
my $iterations = 50;
sub bench_ev_websockets {
print "Benchmarking EV::Websockets Latency ($iterations iterations)...\n";
my $ctx = EV::Websockets::Context->new();
my %srv_conns;
my $port = $ctx->listen(
port => 0,
on_connect => sub { $srv_conns{$_[0]} = $_[0] },
on_close => sub { delete $srv_conns{$_[0]} },
);
my @latencies;
for (1..$iterations) {
my $start = time;
my $c; $c = $ctx->connect(
url => "ws://127.0.0.1:$port",
on_connect => sub {
push @latencies, time - $start;
bench/latency.pl view on Meta::CPAN
printf " Average Latency: %.4f ms\n\n", $avg * 1000;
return $avg;
}
sub bench_ae_ws_client {
print "Benchmarking AnyEvent::WebSocket::Client Latency ($iterations iterations)...\n";
my $ctx = EV::Websockets::Context->new();
my %srv_conns;
my $port = $ctx->listen(
port => 0,
on_connect => sub { $srv_conns{$_[0]} = $_[0] },
on_close => sub { delete $srv_conns{$_[0]} },
);
my @latencies;
for (1..$iterations) {
my $client = AnyEvent::WebSocket::Client->new;
my $start = time;
$client->connect("ws://127.0.0.1:$port")->cb(sub {
my $conn = eval { shift->recv };
push @latencies, time - $start;
view all matches for this distribution
view release on metacpan or search on metacpan
eg/upstream_ad_check.pl view on Meta::CPAN
printf "Querying %s for an A record on %d resolver(s)\n\n", $name, scalar @servers;
printf "%-20s %-7s %-7s %-7s %s\n", 'server', 'rcode', 'ad', 'ra', 'note';
printf "%s\n", '-' x 60;
my $pending = scalar @servers;
my @resolvers; # keep resolvers alive across the for loop iterations;
# otherwise each $r drops to refcount 0 at end-of-iter,
# DESTROY runs ares_destroy, and every callback fires
# with ARES_EDESTRUCTION before we ever pump EV::run.
for my $srv (@servers) {
my $r = EV::cares->new(servers => [$srv], flags => $flags, timeout => 5);
view all matches for this distribution
view release on metacpan or search on metacpan
- (libev) many bugfixes in linuxaio backend.
- (libev) experimental io uring interface.
reminding me to actually release the fix.
- try to name ev.h more explicitly, to hopefully improve portability.
- opportunistically round up wait times for poll and epoll backend,
to avoid unnecessary loop iterations.
- add build dependency on ev_linuxaio.c.
- quickly (re)-ported to minix 3.3 before minix crashed again.
4.27 Thu Jun 27 09:39:58 CEST 2019
- (libev) completely rewritten linuxaio backend, maybe
view all matches for this distribution
view release on metacpan or search on metacpan
t/04-working_with_emacs.t view on Meta::CPAN
echo_home() if $DEBUG;
my $er = Emacs::Run->new;
my $emacs_version = $er->emacs_version;
# Make every other word upper-case - return number of iterations
my $elisp = q{
(let ( (count 0) )
(while (progn
(upcase-word 1) (forward-word 1)
(setq count (+ count 1))
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Encode/Arabic.pm view on Meta::CPAN
# 'use Encode::Arabic ":modes"' would export the functions controlling the conversion modes
Encode::Arabic::demode 'arabtex', 'default';
Encode::Arabic::enmode 'buckwalter', 'full', 'xml', 'strip off kashida';
# Arabic in lower ASCII transliterations <--> Arabic script in Perl's internal encoding
$string = decode 'ArabTeX', $octets;
$octets = encode 'Buckwalter', $string;
$string = decode 'Buckwalter', $octets;
$octets = encode 'ArabTeX', $string;
# Arabic in lower ASCII transliterations <--> Latin phonetic transcription, Perl's utf8
$string = decode 'Buckwalter', $octets;
$octets = encode 'ArabTeX', $string;
$string = decode 'ArabTeX-ZDMG', $octets;
view all matches for this distribution
view release on metacpan or search on metacpan
t/data/demos/12169614.utf8 view on Meta::CPAN
more than 2.5 standard deviations away from the mean was considered an
outlier. Outliers were then removed from the population, and the means
and standard deviations were recalculated. Once again, any spot more
than 2.5 standard deviations away from the mean was considered an
outlier. This process was repeated until few or no outliers were
detected. In these experiments generally three iterations were needed
to identify all outliers in the population.
Array data were also analyzed with the Rosetta Resolver application
Axon error model (Rosetta Biosoftware). The lists of outliers from the
two analysis methods were compared, and only those genes that were
considered significantly changed in both were considered further. The
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Env/Export.pm view on Meta::CPAN
my $prefix = q{};
my $override = 0;
my $split = q{};
# Establish the set of allowable %ENV keys that are eligible for export.
# This will avoid repeated iterations over %ENV later, and will remove
# any keys that could not be used to create valid sub names
my @choices = grep { /^[A-Za-z_]\w*$/ } keys %ENV;
# This list will accumulate the set of subs to be created, in the form of
# metadata:
my @subs = ();
view all matches for this distribution
view release on metacpan or search on metacpan
Eobj/PLerrsys.pm view on Meta::CPAN
# if the $error error string is newline terminated then it
# is copied into $mess. Otherwise, $mess gets set (at the end of
# the 'else' section below) to one of two things. The first time
# through, it is set to the "$error at $file line $line" message.
# $error is then set to 'called' which triggers subsequent loop
# iterations to append $sub to $mess before appending the "$error
# at $file line $line" which now actually reads "called at $file line
# $line". Thus, the stack trace message is constructed:
#
# first time: $mess = $error at $file line $line
# subsequent times: $mess .= $sub $error at $file line $line
view all matches for this distribution
view release on metacpan or search on metacpan
bench/try_tiny.pl view on Meta::CPAN
}));
__END__
Benchmark: timing 500000 iterations of RETURN, manual...
RETURN: 6.84833 wallclock secs ( 6.58 usr + 0.03 sys = 6.61 CPU) @ 75642.97/s (n=500000)
manual: 6.35331 wallclock secs ( 6.31 usr + 0.01 sys = 6.32 CPU) @ 79113.92/s (n=500000)
Rate RETURN manual
RETURN 75643/s -- -4%
manual 79114/s 5% --
Benchmark: timing 10000000 iterations of RETURN, manual...
RETURN: 23.4454 wallclock secs (23.34 usr + 0.03 sys = 23.37 CPU) @ 427899.02/s (n=10000000)
manual: 3.0584 wallclock secs ( 3.02 usr + 0.01 sys = 3.03 CPU) @ 3300330.03/s (n=10000000)
Rate RETURN manual
RETURN 427899/s -- -87%
manual 3300330/s 671% --
view all matches for this distribution
view release on metacpan or search on metacpan
bench/bench.pl view on Meta::CPAN
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use Eshu;
# Benchmark Eshu indentation engines
# Usage: perl bench/bench.pl [iterations]
my $iterations = $ARGV[0] || 100;
# Generate a sizeable C source
my $c_src = generate_c(500);
# Generate a sizeable Perl source
my $pl_src = generate_pl(500);
# Generate a sizeable XS source
my $xs_src = generate_xs(100);
printf "Benchmark: %d iterations each\n", $iterations;
printf "C source: %d lines (%d bytes)\n", scalar(() = $c_src =~ /\n/g), length($c_src);
printf "Perl source: %d lines (%d bytes)\n", scalar(() = $pl_src =~ /\n/g), length($pl_src);
printf "XS source: %d lines (%d bytes)\n", scalar(() = $xs_src =~ /\n/g), length($xs_src);
print "-" x 50, "\n";
bench/bench.pl view on Meta::CPAN
bench("indent_xs", sub { Eshu->indent_xs($xs_src) });
sub bench {
my ($label, $code) = @_;
my $t0 = [gettimeofday];
for (1 .. $iterations) {
$code->();
}
my $elapsed = tv_interval($t0);
printf "%-12s %8.3f ms total %8.3f ms/iter\n",
$label, $elapsed * 1000, ($elapsed / $iterations) * 1000;
}
sub generate_c {
my ($funcs) = @_;
my $out = "#include <stdio.h>\n\n";
view all matches for this distribution
view release on metacpan or search on metacpan
t/Event-Lib-UDPPump.t view on Meta::CPAN
}
my $leaked = Devel::Leak::NoteSV($handle) - $SVcount;
# I'm comparing for < 5 because I've seen issues where this varies by
# a few one way or another with different versions of perl. However,
# we ran 1000 iterations, it should be much more than 5 if there is a
# real leak in the XS.
ok($leaked < 5, "No leaks");
# print "leaked: $leaked\n";
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Excel/Template/Container/Conditional.pm view on Meta::CPAN
<if name="__ODD__" is="false">
... Children here
</if>
In the above example, the children will be executed if the value of __ODD__ (which is set by the L<LOOP|Excel::Template::Container::Loop> node) is false. So, for all even iterations.
=head1 AUTHOR
Rob Kinyon (rob.kinyon@gmail.com)
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
benchmark-all.pl view on Meta::CPAN
}
for ([200,2,4,8], [200,5,4,20], [100,2,10,30], [100,5,10,30], [50,10,50,20], [10,50,50,200]) {
my ($loop, $export_mods, $exports, $packages)= @$_;
print "\nCreating $export_mods modules, each exporting $exports symbols, imported into each of $packages packages\n";
print "$loop iterations (invocations of perl interpreter)\n";
cmpthese($loop, {
'Exporter' => "run_exporter('Exporter',$export_mods,$exports,$packages)",
'Exporter::Tiny' => "run_exporter('Exporter::Tiny',$export_mods,$exports,$packages)",
'Sub::Exporter' => "run_exporter('Sub::Exporter',$export_mods,$exports,$packages)",
'Exporter::Extensible' => "run_exporter('Exporter::Extensible',$export_mods,$exports,$packages)",
view all matches for this distribution
view release on metacpan or search on metacpan
bundled/CPAN-Meta/CPAN/Meta/History.pm view on Meta::CPAN
version 2.143240
=head1 DESCRIPTION
The CPAN Meta Spec has gone through several iterations. It was
originally written in HTML and later revised into POD (though published
in HTML generated from the POD). Fields were added, removed or changed,
sometimes by design and sometimes to reflect real-world usage after the
fact.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ExtUtils/ParseXS/Node.pm view on Meta::CPAN
. "|VERSIONCHECK|INCLUDE|INCLUDE_COMMAND|SCOPE|TYPEMAP";
# Die if the next line is indented: all file-scoped things (CPP,
# keywords, XSUB starts) are supposed to start on column 1
# (although see the comment below about multiple parse_keywords()
# iterations sneaking in indented keywords).
#
if ($pxs->{line}[0] =~ /^\s/) {
# Try to customise the error message based around why this
# line is indented, to better hint to the user what the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
FAST::Bio::Search::Result::CrossMatchResult - CrossMatch-specific subclass of FAST::Bio::Search::Result::GenericResult
=head1 SYNOPSIS
# Working with iterations (CrossMatch results)
$result->next_iteration();
$result->num_iterations();
$result->iteration();
$result->iterations();
# See FAST::Bio::Search::Result::GenericResult for information about working with Results.
# See L<FAST::Bio::Search::Iteration::IterationI|FAST::Bio::Search::Iteration::IterationI>
# for details about working with iterations.
# TODO:
# * Show how to configure a SearchIO stream so that it generates
# CrossMatchResult objects.
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
Usage : my $obj = FAST::Bio::Search::Result::CrossMatchResult->new();
Function: Builds a new FAST::Bio::Search::Result::CrossMatchResult object
Returns : FAST::Bio::Search::Result::CrossMatchResult
Args : See FAST::Bio::Search::Result::GenericResult();
The following parameters are specific to CrossMatchResult:
-iterations => array ref of FAST::Bio::Search::Iteration::IterationI objects
-inclusion_threshold => e-value threshold for inclusion in the
CrossMatch score matrix model (blastpgp)
=cut
sub new {
my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
$self->{'_iterations'} = [];
$self->{'_iteration_index'} = 0;
$self->{'_iteration_count'} = 0;
my( $iters, $ithresh ) = $self->_rearrange([qw(ITERATIONS
INCLUSION_THRESHOLD)],@args);
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
$self->add_iteration($i);
}
}
else {
# This shouldn't get called with the new SearchIO::blast.
#print STDERR "CrossMatchResult::new(): Not adding iterations.\n";
$self->{'_no_iterations'} = 1;
}
#$self->SUPER::algorithm('cross_match');
return $self;
}
=head2 hits
This method overrides L<FAST::Bio::Search::Result::GenericResult::hits> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, all 'new' hits for all iterations are returned.
These are the hits that did not occur in a previous iteration.
See Also: L<FAST::Bio::Search::Result::GenericResult::hits>
=cut
sub hits {
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::hits;
}
my @hits = ();
foreach my $it ($self->iterations) {
push @hits, $it->hits;
}
return @hits;
}
=head2 next_hit
This method overrides L<FAST::Bio::Search::Result::GenericResult::next_hit> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, calling next_hit() traverses the
all of the hits, old and new, for each iteration, calling next_hit() on each iteration.
See Also: L<FAST::Bio::Search::Iteration::GenericIteration::next_hit>
=cut
sub next_hit {
my ($self,@args) = @_;
if ($self->{'_no_iterations'}) {
return $self->SUPER::next_hit(@args);
}
my $iter_index;
if (not defined $self->{'_last_hit'}) {
$iter_index = $self->{'_iter_index'} = $self->_next_iteration_index;
} else {
$iter_index = $self->{'_iter_index'};
}
return if $iter_index >= scalar @{$self->{'_iterations'}};
my $it = $self->{'_iterations'}->[$iter_index];
my $hit = $self->{'_last_hit'} = $it->next_hit;
return defined($hit) ? $hit : $self->next_hit;
}
=head2 num_hits
This method overrides L<FAST::Bio::Search::Result::GenericResult::num_hits> to take
into account the possibility of multiple iterations, as occurs in CrossMatch reports.
If there are multiple iterations, calling num_hits() returns the number of
'new' hits for each iteration. These are the hits that did not occur
in a previous iteration.
See Also: L<FAST::Bio::Search::Result::GenericResult::num_hits>
=cut
sub num_hits{
my ($self) = shift;
if ($self->{'_no_iterations'}) {
return $self->SUPER::num_hits;
}
if (not defined $self->{'_iterations'}) {
$self->throw("Can't get Hits: data not collected.");
}
return scalar( $self->hits );
}
=head2 add_iteration
Title : add_iteration
Usage : $report->add_iteration($iteration)
Function: Adds a IterationI to the stored list of iterations
Returns : Number of IterationI currently stored
Args : FAST::Bio::Search::Iteration::IterationI
=cut
sub add_iteration {
my ($self,$i) = @_;
if( $i->isa('FAST::Bio::Search::Iteration::IterationI') ) {
push @{$self->{'_iterations'}}, $i;
$self->{'_iteration_count'}++;
} else {
$self->throw("Passed in a " .ref($i).
" as a Iteration which is not a FAST::Bio::Search::IterationI.");
}
return scalar @{$self->{'_iterations'}};
}
=head2 next_iteration
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
sub next_iteration {
my ($self) = @_;
unless($self->{'_iter_queue_started'}) {
$self->{'_iter_queue'} = [$self->iterations()];
$self->{'_iter_queue_started'} = 1;
}
return shift @{$self->{'_iter_queue'}};
}
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
Usage : $iteration = $blast->iteration( $number );
Purpose : Get an IterationI object for the specified iteration
in the search result (CrossMatch).
Returns : FAST::Bio::Search::Iteration::IterationI object
Throws : FAST::Bio::Root::NoSuchThing exception if $number is not within
range of the number of iterations in this report.
Argument : integer (optional, if not specified get the last iteration)
First iteration = 1
=cut
sub iteration {
my ($self,$num) = @_;
$num = scalar @{$self->{'_iterations'}} unless defined $num;
unless ($num >= 1 and $num <= scalar $self->{'_iteration_count'}) {
$self->throw(-class=>'FAST::Bio::Root::NoSuchThing',
-text=>"No such iteration number: $num. Valid range=1-$self->{'_iteration_count'}",
-value=>$num);
}
return $self->{'_iterations'}->[$num-1];
}
=head2 num_iterations
Usage : $num_iterations = $blast->num_iterations;
Purpose : Get the number of iterations in the search result (CrossMatch).
Returns : Total number of iterations in the report
Argument : none (read-only)
=cut
sub num_iterations { shift->{'_iteration_count'} }
# Methods provided for consistency with BPpsilite.pm (now deprecated);
# these are now merely synonyms
=head2 number_of_iterations
Same as L<num_iterations>.
=cut
sub number_of_iterations { shift->num_iterations }
=head2 round
Same as L<iteration>.
=cut
sub round { shift->iteration(@_) }
=head2 iterations
Title : iterations
Usage : my @iterations = $result->iterations
Function: Returns the IterationI objects contained within this Result
Returns : Array of L<FAST::Bio::Search::Iteration::IterationI> objects
Args : none
=cut
sub iterations {
my $self = shift;
my @its = ();
if( ref($self->{'_iterations'}) =~ /ARRAY/i ) {
@its = @{$self->{'_iterations'}};
}
return @its;
}
=head2 no_hits_found
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
for hitless reports generated when filtering.
Returns : Boolean
Argument : (optional) integer indicating the iteration number (CrossMatch)
If iteration number is not specified and this is a CrossMatch result,
then this method will return true only if all iterations had
no hits found.
=cut
sub no_hits_found {
my ($self, $round) = @_;
my $result = 0; # final return value of this method.
# Watch the double negative!
# result = 0 means "yes hits were found"
# result = 1 means "no hits were found" (for the indicated iteration or all iterations)
# If a iteration was not specified and there were multiple iterations,
# this method should return true only if all iterations had no hits found.
if( not defined $round ) {
if( $self->{'_iterations'} > 1) {
$result = 1;
foreach my $i( 1..$self->{'_iterations'} ) {
if( not defined $self->{"_iteration_$i"}->{'_no_hits_found'} ) {
$result = 0;
last;
}
}
lib/FAST/Bio/Search/Result/CrossMatchResult.pm view on Meta::CPAN
sub rewind {
my $self = shift;
$self->SUPER::rewind(@_);
$self->{'_iteration_index'} = 0;
foreach ($self->iterations) {
$_->rewind;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/FFI/Platypus/Declare.pm view on Meta::CPAN
for the platform that you are using. This includes strings, opaque and
pointers to other types.
This function is not very fast, so you might want to save this value as
a constant, particularly if you need the size in a loop with many
iterations.
=head2 lang
lang $language;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/FFI/Platypus.pm view on Meta::CPAN
for the platform that you are using. This includes strings, opaque and
pointers to other types.
This function is not very fast, so you might want to save this value as
a constant, particularly if you need the size in a loop with many
iterations.
=head2 alignof
[version 0.21]
view all matches for this distribution