Compare commits
2 commits
2511cc22dd
...
a90da416cd
Author | SHA1 | Date | |
---|---|---|---|
a90da416cd | |||
765d865ca7 |
7 changed files with 10 additions and 14 deletions
|
@ -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
|
CC=gcc
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
@ -17,12 +17,12 @@ docker-image:
|
||||||
|
|
||||||
.PHONY: run-heavy-php
|
.PHONY: run-heavy-php
|
||||||
run-heavy-php:
|
run-heavy-php:
|
||||||
${DOCKER_RUN} php heavy_stuff.php
|
time ${DOCKER_RUN} php heavy_stuff.php
|
||||||
|
|
||||||
.PHONY: run-heavy-php-c
|
.PHONY: run-heavy-php-c
|
||||||
run-heavy-php-c:
|
run-heavy-php-c:
|
||||||
${DOCKER_RUN} php heavy_stuff.
|
time ${DOCKER_RUN} php heavy_stuff_c.php
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm main heavy_stuff.so
|
rm main *.so
|
||||||
|
|
|
@ -10,15 +10,11 @@ function someReallyHeavyStuff($lima, $limb){
|
||||||
}
|
}
|
||||||
$result+=$sum;
|
$result+=$sum;
|
||||||
}
|
}
|
||||||
$result = 0;
|
|
||||||
for($i=0;$i<$lima;$i++){
|
|
||||||
$result+=$sum;
|
|
||||||
}
|
|
||||||
return $result;
|
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.
|
@ -6,7 +6,7 @@ $ffi = FFI::cdef("
|
||||||
|
|
||||||
echo "Hello, also heavy stuff here:\n";
|
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";
|
echo "The heavy result: $result\n";
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ $ffi = FFI::cdef("
|
||||||
|
|
||||||
echo "Hello, less heavy stuff here:\n";
|
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";
|
echo "The heavy result: $result\n";
|
||||||
|
|
||||||
|
|
BIN
php/main
BIN
php/main
Binary file not shown.
|
@ -3,8 +3,8 @@
|
||||||
extern unsigned long some_heavy_stuff(int lima, int limb);
|
extern unsigned long some_heavy_stuff(int lima, int limb);
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
int lima = 1000;
|
int lima = 10000;
|
||||||
int limb = 1000;
|
int limb = 100000;
|
||||||
printf("Hello from blistering C: \n");
|
printf("Hello from blistering C: \n");
|
||||||
printf("Doing stuff: \n");
|
printf("Doing stuff: \n");
|
||||||
unsigned long result = some_heavy_stuff(lima, limb);
|
unsigned long result = some_heavy_stuff(lima, limb);
|
||||||
|
|
Loading…
Reference in a new issue