File: b.pl

package info (click to toggle)
libfile-libmagic-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 524 kB
  • ctags: 849
  • sloc: perl: 1,616; pascal: 88; ansic: 54; makefile: 13
file content (22 lines) | stat: -rw-r--r-- 415 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! perl -w

use lib qw(../blib/lib ../blib/arch ../blib/lib/auto ../blib/arch/auto);

use File::LibMagic ':all';
use Benchmark qw(timethese cmpthese);

my $handle = magic_open(0);
my $ret = magic_load( $handle, "" );

my $r = timethese(
    5000,
    {
        a => sub { my $a = magic_buffer( $handle, "Hi\n" ); },
        b => sub { my $a = MagicBuffer("Hi\n"); },
    }
);

cmpthese($r);

magic_close($handle);