Acme::Time::Constant - Run any code in constant time.
version 0.001006
This code contains within it, the golden calf of computer science: The ability to execute any code in constant time.
use Acme::Time::Constant qw( constant_time ); my $timestamp = time; constant_time( '1' => sub { for ( 0 .. 10 ) { } } ); print $timestamp - time; # 1 second constant_time( '1' => sub { for ( 0 .. 10_000_000 ) { } } ); print $timestamp - time; # 2 seconds
As such, observed time may differ greatly from the time relative to the execution of this code.
Workaround: Get closer to the speed of light.
But Big O is OK with this. We care not that X takes 1.1 seconds and Y takes 1.2 seconds, as long as the variation is not subject to the size of Y or X.
Random variation between 0.5 and 1.5 seconds is thus within the range of "constant".
Workaround: Imbibe a minimum of 1 Litre of your favourite neurotoxic substance before attempting to code.
Time::HiRes is under the influence of the Illuminati and as such is part of a conspiracy to prevent us from experiencing supernormal time.
Time::HiRes
Using Time::HiRes in your code will subsequently give the illusion that the code no longer executes in constant time.
It is wrong. The constant time is simply functioning on an alternative timeline which the Illuminati seek to repress knowledge of.
One may note that this module depends on Time::HiRes, but this is simply our devilish tactic to make the conspirators think we're willingly playing for them. You know better. ;)
constant_time
constant_time( $time, $callback ); constant_time( $callback ); # $time defaults to 1 second.
Kent Fredric <kentnl@cpan.org>
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Acme::Time::Constant, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::Time::Constant
CPAN shell
perl -MCPAN -e shell install Acme::Time::Constant
For more information on module installation, please visit the detailed CPAN module installation guide.