Torque Script Array Implemented
by Hardi Bhatt · in Artist Corner · 05/05/2007 (5:34 am) · 10 replies
I have developed the implementation and use of Arrays in the TS SDK but i done know where the post the finished results. Some of my test results while testing the finished implementations were.
For 1d Arrays of an array size of 125,000
1.5s for the Torque Script symbol table version (Globals ($) and Locals (%))
6.3s for the Torque Script script object version
1.6s for the array implemented version (My version)
For 2D Arrays of an array size 250,000 (500x500)
4.5s for the Torque Script symbol table version (Globals ($) and Locals (%))
42.5s for the Torque Script script object version
4.7s for the array implemented version (My version)
For 3D Array of an array size of 125,000 (50x50x50)
2.9s for the Torque Script symbol table version
11.0s for the Torque Script script object version
2.9s for the array implemented version
I chose to go back to 125000 for the 3D version was because the ScriptObject version was simply taking too long. It works great.
The conventional used for the Public Member Functions are (Different conventions used for more dimensions but same IDEA)
void setSize (int newSize)
int getSize ()
void setValue (int Position)
int getValue ()
The only question is where do i post it.?
For 1d Arrays of an array size of 125,000
1.5s for the Torque Script symbol table version (Globals ($) and Locals (%))
6.3s for the Torque Script script object version
1.6s for the array implemented version (My version)
For 2D Arrays of an array size 250,000 (500x500)
4.5s for the Torque Script symbol table version (Globals ($) and Locals (%))
42.5s for the Torque Script script object version
4.7s for the array implemented version (My version)
For 3D Array of an array size of 125,000 (50x50x50)
2.9s for the Torque Script symbol table version
11.0s for the Torque Script script object version
2.9s for the array implemented version
I chose to go back to 125000 for the 3D version was because the ScriptObject version was simply taking too long. It works great.
The conventional used for the Public Member Functions are (Different conventions used for more dimensions but same IDEA)
void setSize (int newSize)
int getSize ()
void setValue (int Position)
int getValue ()
The only question is where do i post it.?
About the author
#2
Ans. Yes Its works just like a script object where you will first have to new up "create" an array by declaring which dimension its size and what type of array you want (There are 2 types intArray and floatArray and there are 3 dimensions 1D, 2D, and 3D). The convention is %array = new IntArray(); and this " %array" variable can be passed between functions and/or returned.
Here is a test function I created to test the timing of the array implementation
function test1DArrayHB() {
%t = 125000;
%start = getRealTime();
//allocte my array here
%array = new IntArray();
%array.setSize( %t );
for (%i = 0; %i < %t; %i++)
{
%array.setValue(%i, 2*%i);
%x = %array.getValue( %t-%i-1 );
}
%end = getRealTime();
%time = (%end - %start)/1000;
echo("the Total time is: "SPC %time);
echo("The array size is" SPC %t);
}
-Can you implement methods like "push", "slice", "concat" etc? Or doesn't your implementation support variable length arrays?
"concat" is a built in function in TS (@) I have not implemented StringArrays as of yet but the convention seems to be quite similar to implement so once I get started on String implementation I will keep those methods in mind.
05/05/2007 (6:37 am)
-Can you pass them to a function or let a function return them? Currently when using "arrays" you have to put them in an object and pass or return that object.Ans. Yes Its works just like a script object where you will first have to new up "create" an array by declaring which dimension its size and what type of array you want (There are 2 types intArray and floatArray and there are 3 dimensions 1D, 2D, and 3D). The convention is %array = new IntArray(); and this " %array" variable can be passed between functions and/or returned.
Here is a test function I created to test the timing of the array implementation
function test1DArrayHB() {
%t = 125000;
%start = getRealTime();
//allocte my array here
%array = new IntArray();
%array.setSize( %t );
for (%i = 0; %i < %t; %i++)
{
%array.setValue(%i, 2*%i);
%x = %array.getValue( %t-%i-1 );
}
%end = getRealTime();
%time = (%end - %start)/1000;
echo("the Total time is: "SPC %time);
echo("The array size is" SPC %t);
}
-Can you implement methods like "push", "slice", "concat" etc? Or doesn't your implementation support variable length arrays?
"concat" is a built in function in TS (@) I have not implemented StringArrays as of yet but the convention seems to be quite similar to implement so once I get started on String implementation I will keep those methods in mind.
#3
05/05/2007 (8:24 am)
The resource section only allows me to upload 1 class file and i need to upload 12. I need advice on how to resolve this.
#4
Or, can you put them in a zip/tar file and upload that into the resource? I believe I have seen people put up zip files for everyone to download.
05/05/2007 (9:07 am)
Perhaps in the resource section provide instructions, summary, etc... and then a link to a website to download the 12 class files. Or, can you put them in a zip/tar file and upload that into the resource? I believe I have seen people put up zip files for everyone to download.
#5
Thanks
05/08/2007 (7:03 am)
Sorry Guys I have posted up my results under resources but it has not been approved yet! the name is Torque Script array implementation. Please be a little more patient on this one. Thanks
#6
05/15/2007 (8:29 am)
I am for the delay one again! My resource has been posted but has not been approved yet. I don't know what other steps to take in order to have it approved. If you have ant suggestions please let me know.
#7
GG typically approves batches of them all at once.
It may take over a month.
You might consider posting a link to the as-yet-unapproved resource. Other folks will be able to see it.
You can find the link in my account | my posts, where there will be a little section for "unapproved resources".
05/15/2007 (8:56 am)
Hardi - sometimes it can take quite a while for resources to be approved.GG typically approves batches of them all at once.
It may take over a month.
You might consider posting a link to the as-yet-unapproved resource. Other folks will be able to see it.
You can find the link in my account | my posts, where there will be a little section for "unapproved resources".
#8
05/15/2007 (12:48 pm)
Thank you for your suggestion Orion. Here is the link for the "unapproved resources" www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=12863
#9
05/17/2007 (10:25 am)
Please let me know if you like this resource. I am still working on implementing string arrays using the same concept.
#10
05/30/2007 (1:33 pm)
When you guys get a chance please check out my great resource.
Torque Owner Very Interactive Person
Couple of comments/questions though:
-Can you pass them to a function or let a function return them? Currently when using "arrays" you have to put them in an object and pass or return that object.
-Can you implement methods like "push", "slice", "concat" etc? Or doesn't your implementation support variable length arrays?
And where to put it? Just make a resource and post it in the resource section.