Skip to content

Instantly share code, notes, and snippets.

View exodist's full-sized avatar

Chad Granum exodist

View GitHub Profile
use Data::Dumper;
my $stash = \%{"FAKE\::"};
print Dumper([keys %$stash]);
local *FAKE::xxx = sub { 'xxx' };
print Dumper([keys %$stash]);
sub is($$;$) {
my $pass = ... existing implementation ...;
if (!$pass) {
my $two_nums = ...;
my $res = $two_nums && $got == $want;
diag "...you did it wrong..." if $res;
}
return $pass;
}
perl -E 'my $x = {}; my $y = $x; say Internals::SvREFCNT(%{$x})'
2
perl -T -E 'my $x = {}; my $y = $x; say Internals::SvREFCNT(%$x)'
2
perl -T -E 'my $x = {}; my $y = $x; say Internals::SvREFCNT(%{$x})'
3
@exodist
exodist / benchmarks
Last active August 29, 2015 14:22
Test::Stream VS Test::More
Test-Simple version: 1.001014
perl ../Test-Stream/profiling/ok_builder.t 45.36s user 3.91s system 91% cpu 53.955 total
Test-Simple version: 1.001014
perl ../Test-Stream/profiling/ok_builder.t 44.81s user 3.84s system 91% cpu 53.282 total
Test-Simple version: 1.001014
perl ../Test-Stream/profiling/ok_builder.t 46.35s user 3.66s system 91% cpu 54.695 total
-------------------
@exodist
exodist / test.pl
Created May 30, 2015 03:17
This is broken on perls < 5.20
use strict;
use warnings;
sub do_it(&) {
my $sub = shift;
my $finished = 0;
my ($ok, $err);
FOO: {
my $ok = eval { $sub->(); 1 };
$err = $@;
4,6c4,6
< osname=linux, osvers=2.6.32.8-grsec-2.1.14-modsign-xeon-64, archname=x86_64-linux
< uname='linux fubar 2.6.32.8-grsec-2.1.14-modsign-xeon-64 #2 smp sat mar 13 00:42:43 pst 2010 x86_64 gnulinux '
< config_args='-Dprefix=/opt/ndn-perl/cgranum -de -Dotherlibdirs=/opt/ndn-perl/shared/lib/ndn_perl -Duse64bitint -Duse64bitall -Accflags=-fPIC -A'eval:scriptdir=/opt/ndn-perl/cgranum/bin''
---
> osname=linux, osvers=3.13.0-52-generic, archname=x86_64-linux
> uname='linux dev-uebernet-spikes2 3.13.0-52-generic #86~precise1-ubuntu smp tue may 5 18:08:21 utc 2015 x86_64 x86_64 x86_64 gnulinux '
> config_args='-Dprefix=/opt/ndn-perl/dev -de -Dotherlibdirs=/opt/ndn-perl/shared/lib/ndn_perl -Duse64bitint -Duse64bitall -Accflags=-fPIC -A'eval:scriptdir=/opt/ndn-perl/dev/bin''
15c15
< ccversion='', gccversion='4.3.2', gccosandvers=''
@exodist
exodist / Perl -V
Created May 12, 2015 18:04
fast perl
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=linux, osvers=2.6.32-5-amd64, archname=x86_64-linux-gnu-thread-multi
uname='linux barber 2.6.32-5-amd64 #1 smp tue jun 14 09:42:28 utc 2011 x86_64 gnulinux '
config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.0 -Dsitearch=/usr/local/lib/perl/5.10.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.0 -Dd_dosuid -des'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usem
@exodist
exodist / perl -V
Created May 12, 2015 18:01
slow perl
Summary of my perl5 (revision 5 version 20 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.32.8-grsec-2.1.14-modsign-xeon-64, archname=x86_64-linux
uname='linux fubar 2.6.32.8-grsec-2.1.14-modsign-xeon-64 #2 smp sat mar 13 00:42:43 pst 2010 x86_64 gnulinux '
config_args='-Dprefix=/opt/ndn-perl/2015.04.29.111344-9a918e0 -de -Dotherlibdirs=/opt/ndn-perl/shared/lib/ndn_perl -Duse64bitint -Duse64bitall -Accflags=-fPIC -A'eval:scriptdir=/opt/ndn-perl/2015.04.29.111344-9a918e0/bin''
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
unshift @INC => sub {
my ($us, $file) = @_;
return unless $REDIRECT{$file};
my $rewrite = $file;
$rewrite =~ s/\.pm$/_stream.pm/;
require $rewrite;
$INC{$file} = $INC{$rewrite};
@exodist
exodist / gist:93efb79fc227ec799687
Created May 1, 2015 18:33
mongodb error point of problem in Test-Simple
#https://github.com/Test-More/test-more/blob/stream/master/lib/Test/Stream/Context.pm#L263
# expanded:
# This still demonstrates problem:
sub snapshot {
my ($self, $type, $copy, $new);
$self = shift;
$type = blessed($self);
$copy = {%$self};
$new = bless $copy, $type;