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
#define PERL_NO_GET_CONTEXT | |
/* For versions of ExtUtils::ParseXS > 3.04_02, we need to | |
* explicitly enforce exporting of XSUBs since we want to | |
* refer to them using XS(). This isn't strictly necessary, | |
* but it's by far the simplest way to be backwards-compatible. | |
*/ | |
#define PERL_EUPXS_ALWAYS_EXPORT | |
#include "EXTERN.h" | |
#include "perl.h" | |
#include "XSUB.h" |
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
#ifndef PJ_INLINE_H_ | |
#define PJ_INLINE_H_ | |
/* Setup aliases for "static inline" for portability. */ | |
#include <perl.h> | |
/* Alias Perl's */ | |
#define PJ_STATIC STATIC |
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
Here's the results of the following benchmark run on various non-threaded, | |
-O2 perls: | |
{ | |
package O; | |
use overload '""' => sub {}; | |
} | |
my $obj = bless {'x'}, 'P'; | |
my $obj_overload = bless {'x'}, 'O'; |
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
#!perl | |
use 5.14.2; | |
use Redis; | |
use Data::Dumper; | |
use Time::HiRes qw(time); | |
my $r = Redis->new(server => 'localhost:6379'); | |
my $total_count = $r->dbsize; |
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
Which of these OP trees would you expect to execute more quickly? | |
(Provided that other than what you see here, they're doing the same thing!) | |
$ perl_a -MO=Concise -e '@x = @x{1, 2};' | |
g <@> leave[1 ref] vKP/REFC ->(end) | |
1 <0> enter ->2 | |
2 <;> nextstate(main 1 -e:1) v:{ ->3 | |
f <2> aassign[t3] vKS/COMMON ->g | |
- <1> ex-list lK ->c | |
3 <0> pushmark s ->4 |
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
Start benchmark for small ... | |
Sereal Decode ... | |
Sereal Encode ... | |
Sereal OO Decode ... | |
Sereal OO Encode ... | |
MP Decode ... | |
MP Encode ... | |
JSON Decode ... | |
JSON Encode ... | |
CBOR Decode ... |
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
#!perl | |
# Large data structure results | |
# $ perl bench.pl | |
# 2902 | |
# 2653 | |
# 3941 | |
# Benchmark: timing 500000 iterations of json decode, json encode, mp decode, mp encode, sereal decode, sereal encode... | |
# json decode: 22 wallclock secs (22.31 usr + 0.00 sys = 22.31 CPU) @ 22411.47/s (n=500000) | |
# json encode: 12 wallclock secs (10.96 usr + 0.00 sys = 10.96 CPU) @ 45620.44/s (n=500000) |
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
#define NW 0 | |
#define NE 1 | |
#define SW 2 | |
#define SE 3 | |
#include <math.h> | |
#include <limits.h> | |
#include <stdlib.h> | |
#include <EXTERN.h> |
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
PERL_DL_NONLAZY=1 /usr/local/booking-perl/5.8.5/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t | |
t/001_load.........ok | |
t/002_constants....ok | |
t/003_ptable.......ok | |
t/010_desperate.... | |
# Failed test '(plain) correct: blessed regexp with reuse' | |
# at t/010_desperate.t line 47. | |
# got: '"=srl\1\0B,cbar(\245)\r"' | |
# expected: '"=srl\1\0B,cbar(\261cfoobix)\r"' |
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
=head2 Sharing typemaps Between CPAN Distributions | |
Starting with ExtUtils::ParseXS version 3.12 (comes with perl 5.16 | |
and better), it is rather easy to share typemap code between multiple | |
CPAN distributions. The general idea is to share it as a module that | |
offers a certain API and have the dependent modules declare that as a | |
built-time requirement and import the typemap into the XS. An example | |
of such a typemap-sharing module on CPAN is | |
C<ExtUtils::Typemaps::Basic>. Two steps to getting that module's | |
typemaps available in your code: |
NewerOlder