Is asIScriptGeneric::Prepare necessary?
I run the same script context multiple times. From what I understand I need to call Prepare for every Execute. This Prepare call seems to be very slow (because it is doing a lot of checks, resets etc.) My script is very simple, no arguments to the function, but still Prepare takes a lot of time to execute. Do I really need to call this function, is it a faster way to prepare a script execution?
If you intend to execute the same script function, you can call Prepare() with the funcID -1, in which case the function will do less verifications since it can reuse much of the information.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
What about having an instance context for each function you need to call and prepare it just once when you load it?
C ya,Zak McKracken[www.greencatgames.com]
If you intend to call the same function over and over again, it is definitely worth having a dedicated context for that function, but you still need to call Prepare() before each call. Because when the Execute() method finishes it doesn't leave the context in a prepared state. There are for example return values, and parameters on the stack that the application can retrieve. Also if the execution fails for some reason Prepare() must be called to reset the state.
However, I'll see what I can do to minimize the overhead when calling the same function over and over again.
However, I'll see what I can do to minimize the overhead when calling the same function over and over again.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Yes, you're right! Well... you're always right! (in terms of AngelScript, of course! :P
Anyway... thank you very much for all!
By the way, i'm programming a multiplayer action game using your script for AI, some gameplay, weapons, items, etc.
Features:
- Particles
- Multiplayer (client/server)
- Top-down perspective
- Action and sneaking
Well... there's so much to do yet, but i promess you that soon i'll show you something cool... ;)
Anyway... thank you very much for all!
By the way, i'm programming a multiplayer action game using your script for AI, some gameplay, weapons, items, etc.
Features:
- Particles
- Multiplayer (client/server)
- Top-down perspective
- Action and sneaking
Well... there's so much to do yet, but i promess you that soon i'll show you something cool... ;)
C ya,Zak McKracken[www.greencatgames.com]
Sounds cool, I look forward to seeing it in action.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Since we are on the topic...which do you recommend. When doing operations on a WxH array block of pixels with a function DoSomething(float r, float g, float b, float g), do you suggest calling Prepare and executing the function for every pixel or creating a for loop in the script to call the function for every pixel?
The Prepare takes time to set up, but does calling the function from the script take more,less or the same time to execute?
I don't really have anything solid I use AS for yet, just toying around with it in a couple of areas.
The Prepare takes time to set up, but does calling the function from the script take more,less or the same time to execute?
I don't really have anything solid I use AS for yet, just toying around with it in a couple of areas.
Interesting question. I don't have an obvious answer, it would be necessary to test both solutions to see which was faster.
Prepare(-1) have relatively little overhead, but you will have to call SetArgFloat() 4 times for each of the calls. It might just be that doing the loop inside the script is faster.
Calling the DoSomething() function from within the script is faster than calling Prepare(-1), SetArgFloat()x4, Execute() from the application, but doing the loop in the script and possibly updating the arguments for each pixel is slower than in the application.
Which solution is faster would depend on how much else is done in the loop, I guess.
[edit]Just noticed that the title of this thread is wrong, it should be asIScriptContext instead of asIScriptGeneric [wink][/edit]
Prepare(-1) have relatively little overhead, but you will have to call SetArgFloat() 4 times for each of the calls. It might just be that doing the loop inside the script is faster.
Calling the DoSomething() function from within the script is faster than calling Prepare(-1), SetArgFloat()x4, Execute() from the application, but doing the loop in the script and possibly updating the arguments for each pixel is slower than in the application.
Which solution is faster would depend on how much else is done in the loop, I guess.
[edit]Just noticed that the title of this thread is wrong, it should be asIScriptContext instead of asIScriptGeneric [wink][/edit]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement