Convert-Binary-C
view release on metacpan or search on metacpan
tests/601_speed.t view on Meta::CPAN
$time_per_test = 1;
}
$cache = 'tests/cache.cbc';
-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--;
$next_test_time += $time_per_test;
ok(1);
}
}
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 );
$c->parse_file( 'tests/include/include.c' );
};
ok($@,'',"failed to create cache file for speed test");
# not ok if cache file doesn't exist now
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 );
-e $cache and unlink $cache;
tests/include/pdclib/functions/_tzcode/_PDCLIB_mktime_tzname.c view on Meta::CPAN
*/
#ifndef REGTEST
#include "pdclib/_PDCLIB_tzcode.h"
/* Adapted from code provided by Robert Elz, who writes:
The "best" way to do mktime I think is based on an idea of Bob
Kridle's (so its said...) from a long time ago.
It does a binary search of the time_t space. Since time_t's are
just 32 bits, its a max of 32 iterations (even at 64 bits it
would still be very reasonable).
*/
#ifndef WRONG
#define WRONG (-1)
#endif
/* Normalize logic courtesy Paul Eggert. */
static bool increment_overflow32( int_fast32_t * lp, int m )
( run in 1.339 second using v1.01-cache-2.11-cpan-96521ef73a4 )