Compare commits

...

2 commits

Author SHA1 Message Date
a90da416cd Ref 2025-01-08 23:37:05 +00:00
765d865ca7 Refactorings 2025-01-08 23:36:15 +00:00
7 changed files with 10 additions and 14 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:
${DOCKER_RUN} php heavy_stuff.php
time ${DOCKER_RUN} php heavy_stuff.php
.PHONY: run-heavy-php-c
run-heavy-php-c:
${DOCKER_RUN} php heavy_stuff.
time ${DOCKER_RUN} php heavy_stuff_c.php
.PHONY: clean
clean:
rm main heavy_stuff.so
rm main *.so

View file

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

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,1000);
$result = $ffi->some_heavy_stuff(1000,100000);
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(1000,1000);
$result = $ffi->lesser_heavy_stuff(10000,100000);
echo "The heavy result: $result\n";

BIN
php/main

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 = 1000;
int limb = 1000;
int lima = 10000;
int limb = 100000;
printf("Hello from blistering C: \n");
printf("Doing stuff: \n");
unsigned long result = some_heavy_stuff(lima, limb);