Skip to content

Instantly share code, notes, and snippets.

View schwern's full-sized avatar

Michael G. Schwern schwern

View GitHub Profile
@schwern
schwern / gist:9942847
Created April 2, 2014 20:49
The fibnonacci sequence implemented as a method on an integer class, with caching, for demonstration purposes.
#!/usr/bin/perl
use perl5i::2;
# A full on Integer class.
{
package Integer;
use perl5i::2;
use Method::Signatures;
@schwern
schwern / gist:9942770
Last active August 29, 2015 13:58
The fibnonacci sequence implemented as a method on an autoboxed integer/scalar class, with caching, for demonstration purposes.
#!/usr/bin/perl
# This turns on function signatures and autoboxing
# amongst a lot of other things.
use perl5i::2;
# This class adds methods callable on all scalar variables.
{
package SCALAR;
use perl5i::2;
@schwern
schwern / builtin_vs_ms_runtime
Created March 26, 2014 19:39
5.20 signatures vs Method::Signatures, runtime benchmark
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use Benchmark qw(cmpthese);
{
package MS;
@schwern
schwern / builtin_vs_ms_compile
Last active August 29, 2015 13:57
5.20 signatures vs Method::Signatures - compile time benchmark at realistic scales
#!/usr/bin/perl
use v5.19;
use strict;
use warnings;
# This isn't strictly necessary, I just want to use them.
use feature 'signatures';
no warnings 'experimental::signatures';
#!/usr/bin/env perl
use strict;
use warnings;
use Date::Manip::Date;
my($command_date_string, @command) = @ARGV;
my $command_date = Date::Manip::Date->new;
#!/usr/bin/env perl
# Hand it something like EVO/Class-MakeMethods-1.01.tar.gz on STDIN
use perl5i::2;
use MetaCPAN::API;
my %Releases;
my @Missing;
@schwern
schwern / gist:3942210
Created October 23, 2012 22:39
Unblocking with cond_broadcast does not conflict
# Test that unblocking all threads at once using cond_broadcast won't
# cause them to collide with each other.
use strict;
use warnings;
use Config;
BEGIN {
if (! $Config{'useithreads'}) {
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
cmpthese shift || -3, {
"shift" => sub {
my $arg = shift;
@schwern
schwern / gist:3239960
Created August 2, 2012 19:33
Benchmark Sub::Quote
#!/usr/bin/env perl
use strict;
use warnings;
use Sub::Quote;
use Benchmark qw(cmpthese);
my $qs = Sub::Quote::inlinify q{my $foo = 23; my $bar = 42; my $biff = 99}, '';
[color]
# Turn on colors as applicable
ui = auto
[alias]
# Shortcuts
st = status
br = branch
co = checkout