Skip to content

Instantly share code, notes, and snippets.

@mohawk2
mohawk2 / pdl-random.txt
Created April 13, 2024 22:44
PDL->random timings with and without pthreading
$each = 1e7; $q = int(1e8/$each); with_time { PDL->random($each) for 1..$q }
set_autopthread_size(0)
$each approx time
1e8 1000ms
1e7 1050ms
1e6 700ms
1e5 740ms
1e4 2500ms
@mohawk2
mohawk2 / bitvec-thing.pl
Last active January 7, 2021 02:30
Performance comparison looking up indices of set bits in Perl bit-vectors using vec() versus unpack "b*" and regex
use strict;
use warnings;
use Time::HiRes qw(time);
my ($SPARSEX, $SPARSEY) = (1100, 1);
my $DIMS = 50000;
sub set2 {
my ($m) = @_;
for my $y (0..int($DIMS / $SPARSEY)) {
@mohawk2
mohawk2 / benchmark-param-validation-practical.pl
Last active September 24, 2017 03:11 — forked from tobyink/benchmark-param-validation-practical.pl
Speed comparison between Type::Params and Params::Validate (PP and XS) and Function::Parameters
use 5.012;
use Benchmark qw( cmpthese timethese );
use Test::Deep::NoTest;
use Scalar::Util qw(looks_like_number);
use Params::Validate qw(SCALAR HASHREF ARRAYREF);
my @SIG = (
{ type => SCALAR, callbacks => { looks_like_number => sub { looks_like_number($_[0]) } } },
{ type => HASHREF },
I have the 8 Ball in my back pocket. I figure that makes me kind of a defense contractor. And I ought to get paid like one, meaning grossly overpaid. -- Richard Kadrey: Kill City Blues
There's only one way to avoid criticism: do nothing, say nothing, be nothing. -- Aristotle
Two possibilities exist: Either we are alone in the Universe, or we are not. Both are equally terrifying. -- Arthur C. Clarke
History is a set of lies agreed upon. -- Napoleon Bonaparte
The only time the word "incorrectly" isn't spelled incorrectly is when it's spelled incorrectly.
Back when PHP had less than 100 functions, the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the various function name lengths, names were picked specifically to make them fit into a specific length bucket. -- Rasmus Lerdorf
<Raborn> I just read a book about Stockholm Syndrome. It was pretty bad at first, but by the end I kinda liked it.
What language do deaf people think in?
"A five-tailed fox!" Owen
@mohawk2
mohawk2 / perltext.pod
Last active August 29, 2015 14:05
Perl Text

NAME

perltext - Perl Text thoughts

DESCRIPTION

This document assumes you have read perlunitut, which in turn assumes you understand the distinction between characters and octets, and that a "string" is a sequence of characters (aka codepoints).