-
-
Save wchristian/e431b1473b5f1cb45742fcdb42d31b4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=pod | |
d:\cpan\OpenGL>perl benchl.pl | |
true constant 0.118 | |
xs constant 0.123 | |
eval constant 0.238 | |
func constant 0.121 | |
glob constant 0.116 | |
mod constant 0.117 | |
scal constant 0.114 | |
scalar 0.116 | |
true constant 0.125 | |
xs constant 0.125 | |
eval constant 0.236 | |
func constant 0.119 | |
glob constant 0.122 | |
mod constant 0.116 | |
scal constant 0.119 | |
scalar 0.119 | |
=cut | |
use 5.010; | |
use strictures; | |
use Time::HiRes 'time'; | |
use OpenGL::Modern qw' glEnable GL_MAX_3D_TEXTURE_SIZE'; | |
use Const::Fast; | |
sub GL_MAX_3D_TEXTURE_SIZEp(); | |
eval " | |
sub GL_MAX_3D_TEXTURE_SIZEp() { " . ( 1 + GL_MAX_3D_TEXTURE_SIZE ) . " }; | |
1; | |
" or die $@; | |
sub GL_MAX_3D_TEXTURE_SIZEc() { 32885 } | |
BEGIN { | |
no strict 'refs'; | |
my $num = 3 + GL_MAX_3D_TEXTURE_SIZE; | |
*{ __PACKAGE__ . "::GL_MAX_3D_TEXTURE_SIZEnostrict" } = sub () { $num }; | |
} | |
BEGIN { | |
require constant; | |
constant->import( GL_MAX_3D_TEXTURE_SIZEimport => 4 + GL_MAX_3D_TEXTURE_SIZE ); | |
} | |
const my $GL_MAX_3D_TEXTURE_SIZE => 32885; | |
my $GL_MAX_3D_TEXTURE_SIZEn = 32885; | |
my @counts = 1 .. 1_000_000; | |
my $c = GL_MAX_3D_TEXTURE_SIZE; | |
$c = GL_MAX_3D_TEXTURE_SIZEp; | |
$c = GL_MAX_3D_TEXTURE_SIZEc; | |
$c = GL_MAX_3D_TEXTURE_SIZEnostrict; | |
$c = GL_MAX_3D_TEXTURE_SIZEimport; | |
run(); | |
sub run { | |
my $start = time; | |
glEnable 32885 for @counts; | |
$start = time; | |
glEnable 32885 for @counts; | |
say sprintf "true constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZE for @counts; | |
say sprintf "xs constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEp for @counts; | |
say sprintf "eval constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEc for @counts; | |
say sprintf "func constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEnostrict for @counts; | |
say sprintf "glob constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEimport for @counts; | |
say sprintf "mod constant %.3f", time - $start; | |
$start = time; | |
glEnable $GL_MAX_3D_TEXTURE_SIZE for @counts; | |
say sprintf "scal constant %.3f", time - $start; | |
$start = time; | |
glEnable $GL_MAX_3D_TEXTURE_SIZEn for @counts; | |
say sprintf "scalar %.3f", time - $start; | |
say ""; | |
$start = time; | |
glEnable 32885 for @counts; | |
say sprintf "true constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZE for @counts; | |
say sprintf "xs constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEp for @counts; | |
say sprintf "eval constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEc for @counts; | |
say sprintf "func constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEnostrict for @counts; | |
say sprintf "glob constant %.3f", time - $start; | |
$start = time; | |
glEnable GL_MAX_3D_TEXTURE_SIZEimport for @counts; | |
say sprintf "mod constant %.3f", time - $start; | |
$start = time; | |
glEnable $GL_MAX_3D_TEXTURE_SIZE for @counts; | |
say sprintf "scal constant %.3f", time - $start; | |
$start = time; | |
glEnable $GL_MAX_3D_TEXTURE_SIZEn for @counts; | |
say sprintf "scalar %.3f", time - $start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment