@ Alexandre: sure, no problem !
@ Luc:
I'm not sure how much code I can provide without being to specific, but here is how it goes :
- Let's say I have the Smalltalk code bellow:
MyClass>>withNBCall
���� externalArray := NBExternalArrayOfDoubles new: self internalArray size.
���� output := NBExternalArrayOfDoubles new: 4.
���� [
self actualNBCallWith:
externalArray adress storeResultIn:
output adress] ensure: [
externalArray free.
output free].
MyClass>>withNBCallCommented
���� externalArray := NBExternalArrayOfDoubles new: self internalArray size.
���� output := NBExternalArrayOfDoubles new: 4.
���� [
"self actualNBCallWith: externalArray adress storeResultIn: output adress"] ensure: [
externalArray free.
output free].
MyClass>>actualNBCallWith:
externalArray storeResultIn:
output���� <
primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: errorCode>
���� ^self nbCall: #(void callToC(double * externalArray, double * output)) module: 'lib/myModule.dll'
void callToC(double * externalArray, double * output) {
���� computationWith(externalArray, output);
}
void specialCallToC(double * externalArray, double * output) {
���� unsigned int i;
���� for (i = 0; i < 24*3600; i++)
���������� computationWith(externalArray, output);
}
- Now I have the following code typed in Time Profiler tool :
object := (MyClass new) variousInitialization; yourself
24*3600 timesRepeat: [
object withNBCall]
>> Over 1 minute computation time of which over 99% are primitives. Also I don't see the nbCall: in the tree.
object := (MyClass new) variousInitialization; yourself
24*3600 timesRepeat: [
object withNBCallCommented]
>> Less than 1 second.
object := (MyClass new) variousInitialization; yourself
object withNBCall
>> Less than 1 millisecond.
object := (MyClass new) variousInitialization; yourself
object withNBSpecialCall
"This time, I use the specialCallToC() function"
>> Arround 20 millisecond.
Allright, that's a pile of code but I hope it help :)
On a side note:
- Pharo 3, Win 7 32-bit
- I'm not at work anymore and don't have my code with me. So I will double check tomorow that I didn't provided false informations but I think it's accurate of what I do.
Again, thanks for the interest on my issue !
Thomas.