Hello,

I've a problem compiling a small programm, in which i tried to Benchmark the
difference between Inline::C and unpack.

This programm is not compiling(problem with Inline_Stack ??). Does someone
know, what i'm doing wrong?

#!/usr/bin/perl
use Benchmark;

timethese(1000000, {
   c => sub {
    foreach (split(',', '0400x0200,0600x0100,0142x0070')) {
      my ($x, $y) = xy($_);
    }
  },
  unpack => sub {
    foreach (split(',', '0400x0200,0600x0100,0142x0070')) {
      my ($x, $y) = unpack("a4 x1 a4", $_);
    }
  }
});

use Inline C => <<'END';
void xy(char* str) {
  int i = 0;
  char c;
  int x = 0;
  int y = 0;

  while(c = str[i++]) {
    if (i > 5) {
      y = 10 * y + c - '0';
    } else if(i < 5) {
      x = 10 * x + c - '0';
    }
  }

  Inline_Stack_Vars;
  Inline_Stack_Reset;

  Inline_Stack_Push(newSViv(x));
  Inline_Stack_Push(newSViv(y));

  Inline_Stack_Done;
}
END

Reply via email to