Compare commits

..

No commits in common. "a90da416cd39fa0c71a90170b85edc73dfe7c1f7" and "2511cc22dd3b09867043e4ce0bb3870b3ef5d980" have entirely different histories.

7 changed files with 14 additions and 10 deletions

View file

@ -1,4 +1,4 @@
DOCKER_RUN=docker run -it --rm -v "$${PWD}:/usr/src/myapp" -w /usr/src/myapp php/ffi
DOCKER_RUN=docker run -it --rm -v "$PWD:/usr/src/myapp" -w /usr/src/myapp php/ffi
CC=gcc
.PHONY: all
@ -17,12 +17,12 @@ docker-image:
.PHONY: run-heavy-php
run-heavy-php:
time ${DOCKER_RUN} php heavy_stuff.php
${DOCKER_RUN} php heavy_stuff.php
.PHONY: run-heavy-php-c
run-heavy-php-c:
time ${DOCKER_RUN} php heavy_stuff_c.php
${DOCKER_RUN} php heavy_stuff.
.PHONY: clean
clean:
rm main *.so
rm main heavy_stuff.so

View file

@ -10,11 +10,15 @@ function someReallyHeavyStuff($lima, $limb){
}
$result+=$sum;
}
$result = 0;
for($i=0;$i<$lima;$i++){
$result+=$sum;
}
return $result;
}
$r = someReallyHeavyStuff(1000,100000);
$result = someReallyHeavyStuff(1000,1000);
echo "The heavy result: $r\n"
echo "The heavy result: $result\n"
?>

BIN
php/heavy_stuff.so Executable file

Binary file not shown.

View file

@ -6,7 +6,7 @@ $ffi = FFI::cdef("
echo "Hello, also heavy stuff here:\n";
$result = $ffi->some_heavy_stuff(1000,100000);
$result = $ffi->some_heavy_stuff(1000,1000);
echo "The heavy result: $result\n";

View file

@ -6,7 +6,7 @@ $ffi = FFI::cdef("
echo "Hello, less heavy stuff here:\n";
$result = $ffi->lesser_heavy_stuff(10000,100000);
$result = $ffi->lesser_heavy_stuff(1000,1000);
echo "The heavy result: $result\n";

BIN
php/main Executable file

Binary file not shown.

View file

@ -3,8 +3,8 @@
extern unsigned long some_heavy_stuff(int lima, int limb);
int main(void) {
int lima = 10000;
int limb = 100000;
int lima = 1000;
int limb = 1000;
printf("Hello from blistering C: \n");
printf("Doing stuff: \n");
unsigned long result = some_heavy_stuff(lima, limb);