#!/usr/bin/perl # Create 1 GB file if you do not have one: # dd if=/dev/urandom of=test.bin bs=1048576 count=1000 use strict; use warnings; use Sys::Mmap; open (my $fh, "test.bin") or die "open: $!"; my $t = time; print "mmapping.. "; mmap (my $mh, 0, PROT_READ, MAP_SHARED, $fh) or die "mmap: $!"; my @all_b = $mh =~ /0xb/g; my $cnt = @all_b; my $runtime = time()-$t; print STDERR "found $cnt 0xb, in $runtime seconds\n";