Nevitro Posted May 11, 2013 Share Posted May 11, 2013 (edited) Hello programmers. First, there is my code [copy that and paste into txt file, after that name this "Nevitrotest.cs"]: using System;using System.Windows.Forms;using GTA;namespace Nevitrotest{public class SCRIPT_SPEED_TEST : Script{bool run_test=false;double summarum;int time_run,time_run_limit=10,x,interval=0;int[] getallx = new int[10]; public SCRIPT_SPEED_TEST() { this.Tick += this.TICK_DO_ALL_TIME; Game.Console.Print("------------------------------\n Nevitro script testing how much time run script with different Interval\n Type 'nvconfig' or 'nvtest'"); BindConsoleCommand("nvtest", new ConsoleCommandDelegate(RUN_TEST)); BindConsoleCommand("nvconfig", new ConsoleCommandDelegate(TEST_CONFIG)); }public void RUN_TEST(ParameterCollection Parameter){Game.Console.Print("Please wait... Test will run in :");Wait(1000);Game.Console.Print("3...");Wait(1000);Game.Console.Print("2..");Wait(1000);Game.Console.Print("1...");Wait(1000);Game.Console.Close();Game.DisplayText("Testing script speed RUN");run_test = true;x=0;time_run=1;summarum=0;GTA.Native.Function.Call("SETTIMERC", 0);}public void TEST_CONFIG(ParameterCollection Parameter){Wait(100);Game.Console.Close();Game.Console.Print("\n------------------INTERVAL CONFIG NEVITRO SCRIPT\n Please, close this console and set interval with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change interval, just press Enter after close console\n TIP: Bigger interval will give smaller amount speed of script. \n Scripts should run lees times than normal [interval=0]");Game.DisplayText("How big interval for script You want?");do {Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){interval=interval+1;Game.DisplayText("Interval ="+interval);}if (Game.isKeyPressed(Keys.Down)){interval=interval-1;if (interval<0) interval=0;Game.DisplayText("Interval ="+interval);}Wait(20);}while (!(Game.isKeyPressed(Keys.Enter)));Wait(100);Game.Console.Print("\n------------------HOW MUCH TEST CONFIG NEVITRO SCRIPT\n Please, close this console and set how much tests You want with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change amount of tests, just press Enter after close console\n Bigger amount mean more accurate results. \n");Game.DisplayText("How much tests You want? for script You want?");do{Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){time_run_limit=time_run_limit+1;Game.DisplayText("Amount of tests ="+time_run_limit);}if (Game.isKeyPressed(Keys.Down)){time_run_limit=time_run_limit-1;if (time_run_limit<1) time_run_limit=1;Game.DisplayText("Amount of tests ="+time_run_limit);}Wait(50);}while (!(Game.isKeyPressed(Keys.Enter)));Player.CanControlCharacter = true;Game.Console.Open();Game.Console.Print("Interval of script is "+interval+" ms");Game.Console.Print("Amount tests of script is "+time_run_limit+"\n");Game.Console.Print("Type here 'nvtest'");} public void TICK_DO_ALL_TIME(object sender, EventArgs e) { if (run_test==true) { if (GTA.Native.Function.Call<int>("TIMERC")<1000) { x=x+1; Wait(interval); } else { Game.DisplayText("Testing speed ..."); getallx[time_run-1]=x; Game.Console.Print("Test "+time_run+" run "+x+" times."); time_run=time_run+1; x=0; GTA.Native.Function.Call("SETTIMERC", 0); if (time_run==(time_run_limit+1)) { for (int xyz=0; xyz<=9; xyz++) { summarum=summarum+getallx[xyz]; } summarum=summarum/time_run_limit; run_test=false; Game.Console.Print("AVG times how much run script: "+Math.Round(summarum,0)+"\nwith interval: "+interval+"\nand with "+time_run_limit+" tests"); Game.DisplayText("Testing script speed STOP"); Game.Console.Open(); } } }}}} Codes allowed in game console: "nvconfig" "nvtest" nvconfig is for set interval and limits tests in game. Interval is it time before script do next loop. Second option, limit of tests, allow to user make very accurace test. Bigger value give more precise results. nvtest - make test. When test run, You can do anything. Also play with others scripts. Instructions: This scripts generaly is for developers, but also normal user can use this like benchmark for scripts. If interval is 0 and You have big amount of AVG it is good. If Your AVG amount is under 20 - Your computer must really work hard now. Try to disable some programs in Windows and run again this test. Better? Please write here. Developer on this script, can see what is difference for computer if interval is not set to 1 or 2... Why i say this? Because in GTA 4, many programmist think everyone super computer. Why script must check every milisecond what we do? For me, 10 scripts running and added "this.Interval = 1" make my game run faster... Only 1 ms for every script... So, with my script You can see in different locations, situations how many loops do script. Your script also should do same amount of loops. I just left for You to fun. Small, fast benchmark Forgot, my results [5 AVG for one situation]: Small window, the lowest graphic, interval 0, place near house: 26, 25, 24,26,25 Fullscreen, medium graphic, interval 0, that same place: 15,16,17,16,16 Fullscreen, medium graphic, interval 1, that same place: 16,16,16,15,14 1 loop less, for simple x=x+1 script... what should if You put there some more diffucult things to do? I do not have time for this now, but test for Yourself Edited May 11, 2013 by Nevitro Link to comment Share on other sites More sharing options...
julionib Posted May 12, 2013 Share Posted May 12, 2013 i use 10 ms of interval, what kills me is the lag ares where Wait(1000) wait more than one sec hehe Link to comment Share on other sites More sharing options...
Nevitro Posted May 12, 2013 Author Share Posted May 12, 2013 Must add limit for more than 1000 ms Link to comment Share on other sites More sharing options...
blowjobcumpussy Posted May 13, 2013 Share Posted May 13, 2013 nice i will test myself soon, btw u can do x++; instead of x = x+ 1; Link to comment Share on other sites More sharing options...
Nevitro Posted May 13, 2013 Author Share Posted May 13, 2013 Yeah i know, but sometimes if didn't work i just write to more simple [for me] code... I use "x++" most times only in For Link to comment Share on other sites More sharing options...
pedro2555 Posted June 13, 2013 Share Posted June 13, 2013 Sorry if I look out of place, but what exactly TIMERC returns ? Link to comment Share on other sites More sharing options...
Nevitro Posted June 14, 2013 Author Share Posted June 14, 2013 It is game timer, return miliseconds in "int". Link to comment Share on other sites More sharing options...
Jakes625 Posted July 6, 2013 Share Posted July 6, 2013 Hello programmers. First, there is my code [copy that and paste into txt file, after that name this "Nevitrotest.cs"]: using System;using System.Windows.Forms;using GTA;namespace Nevitrotest{public class SCRIPT_SPEED_TEST : Script{bool run_test=false;double summarum;int time_run,time_run_limit=10,x,interval=0;int[] getallx = new int[10]; public SCRIPT_SPEED_TEST() { this.Tick += this.TICK_DO_ALL_TIME; Game.Console.Print("------------------------------\n Nevitro script testing how much time run script with different Interval\n Type 'nvconfig' or 'nvtest'"); BindConsoleCommand("nvtest", new ConsoleCommandDelegate(RUN_TEST)); BindConsoleCommand("nvconfig", new ConsoleCommandDelegate(TEST_CONFIG)); }public void RUN_TEST(ParameterCollection Parameter){Game.Console.Print("Please wait... Test will run in :");Wait(1000);Game.Console.Print("3...");Wait(1000);Game.Console.Print("2..");Wait(1000);Game.Console.Print("1...");Wait(1000);Game.Console.Close();Game.DisplayText("Testing script speed RUN");run_test = true;x=0;time_run=1;summarum=0;GTA.Native.Function.Call("SETTIMERC", 0);}public void TEST_CONFIG(ParameterCollection Parameter){Wait(100);Game.Console.Close();Game.Console.Print("\n------------------INTERVAL CONFIG NEVITRO SCRIPT\n Please, close this console and set interval with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change interval, just press Enter after close console\n TIP: Bigger interval will give smaller amount speed of script. \n Scripts should run lees times than normal [interval=0]");Game.DisplayText("How big interval for script You want?");do {Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){interval=interval+1;Game.DisplayText("Interval ="+interval);}if (Game.isKeyPressed(Keys.Down)){interval=interval-1;if (interval<0) interval=0;Game.DisplayText("Interval ="+interval);}Wait(20);}while (!(Game.isKeyPressed(Keys.Enter)));Wait(100);Game.Console.Print("\n------------------HOW MUCH TEST CONFIG NEVITRO SCRIPT\n Please, close this console and set how much tests You want with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change amount of tests, just press Enter after close console\n Bigger amount mean more accurate results. \n");Game.DisplayText("How much tests You want? for script You want?");do{Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){time_run_limit=time_run_limit+1;Game.DisplayText("Amount of tests ="+time_run_limit);}if (Game.isKeyPressed(Keys.Down)){time_run_limit=time_run_limit-1;if (time_run_limit<1) time_run_limit=1;Game.DisplayText("Amount of tests ="+time_run_limit);}Wait(50);}while (!(Game.isKeyPressed(Keys.Enter)));Player.CanControlCharacter = true;Game.Console.Open();Game.Console.Print("Interval of script is "+interval+" ms");Game.Console.Print("Amount tests of script is "+time_run_limit+"\n");Game.Console.Print("Type here 'nvtest'");} public void TICK_DO_ALL_TIME(object sender, EventArgs e) { if (run_test==true) { if (GTA.Native.Function.Call<int>("TIMERC")<1000) { x=x+1; Wait(interval); } else { Game.DisplayText("Testing speed ..."); getallx[time_run-1]=x; Game.Console.Print("Test "+time_run+" run "+x+" times."); time_run=time_run+1; x=0; GTA.Native.Function.Call("SETTIMERC", 0); if (time_run==(time_run_limit+1)) { for (int xyz=0; xyz<=9; xyz++) { summarum=summarum+getallx[xyz]; } summarum=summarum/time_run_limit; run_test=false; Game.Console.Print("AVG times how much run script: "+Math.Round(summarum,0)+"\nwith interval: "+interval+"\nand with "+time_run_limit+" tests"); Game.DisplayText("Testing script speed STOP"); Game.Console.Open(); } } }}}} Codes allowed in game console: "nvconfig" "nvtest" nvconfig is for set interval and limits tests in game. Interval is it time before script do next loop. Second option, limit of tests, allow to user make very accurace test. Bigger value give more precise results. nvtest - make test. When test run, You can do anything. Also play with others scripts. Instructions: This scripts generaly is for developers, but also normal user can use this like benchmark for scripts. If interval is 0 and You have big amount of AVG it is good. If Your AVG amount is under 20 - Your computer must really work hard now. Try to disable some programs in Windows and run again this test. Better? Please write here. Developer on this script, can see what is difference for computer if interval is not set to 1 or 2... Why i say this? Because in GTA 4, many programmist think everyone super computer. Why script must check every milisecond what we do? For me, 10 scripts running and added "this.Interval = 1" make my game run faster... Only 1 ms for every script... So, with my script You can see in different locations, situations how many loops do script. Your script also should do same amount of loops. I just left for You to fun. Small, fast benchmark Forgot, my results [5 AVG for one situation]: Small window, the lowest graphic, interval 0, place near house: 26, 25, 24,26,25 Fullscreen, medium graphic, interval 0, that same place: 15,16,17,16,16 Fullscreen, medium graphic, interval 1, that same place: 16,16,16,15,14 1 loop less, for simple x=x+1 script... what should if You put there some more diffucult things to do? I do not have time for this now, but test for Yourself DateTime start = DateTime.Now; //do stuff DateTime end = DateTime.Now; string Duration = (end - start).seconds.ToString(); ? Link to comment Share on other sites More sharing options...
pedro2555 Posted July 8, 2013 Share Posted July 8, 2013 (edited) Hello programmers. First, there is my code [copy that and paste into txt file, after that name this "Nevitrotest.cs"]: using System;using System.Windows.Forms;using GTA;namespace Nevitrotest{public class SCRIPT_SPEED_TEST : Script{bool run_test=false;double summarum;int time_run,time_run_limit=10,x,interval=0;int[] getallx = new int[10]; public SCRIPT_SPEED_TEST() { this.Tick += this.TICK_DO_ALL_TIME; Game.Console.Print("------------------------------\n Nevitro script testing how much time run script with different Interval\n Type 'nvconfig' or 'nvtest'"); BindConsoleCommand("nvtest", new ConsoleCommandDelegate(RUN_TEST)); BindConsoleCommand("nvconfig", new ConsoleCommandDelegate(TEST_CONFIG)); }public void RUN_TEST(ParameterCollection Parameter){Game.Console.Print("Please wait... Test will run in :");Wait(1000);Game.Console.Print("3...");Wait(1000);Game.Console.Print("2..");Wait(1000);Game.Console.Print("1...");Wait(1000);Game.Console.Close();Game.DisplayText("Testing script speed RUN");run_test = true;x=0;time_run=1;summarum=0;GTA.Native.Function.Call("SETTIMERC", 0);}public void TEST_CONFIG(ParameterCollection Parameter){Wait(100);Game.Console.Close();Game.Console.Print("\n------------------INTERVAL CONFIG NEVITRO SCRIPT\n Please, close this console and set interval with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change interval, just press Enter after close console\n TIP: Bigger interval will give smaller amount speed of script. \n Scripts should run lees times than normal [interval=0]");Game.DisplayText("How big interval for script You want?");do {Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){interval=interval+1;Game.DisplayText("Interval ="+interval);}if (Game.isKeyPressed(Keys.Down)){interval=interval-1;if (interval<0) interval=0;Game.DisplayText("Interval ="+interval);}Wait(20);}while (!(Game.isKeyPressed(Keys.Enter)));Wait(100);Game.Console.Print("\n------------------HOW MUCH TEST CONFIG NEVITRO SCRIPT\n Please, close this console and set how much tests You want with UP/DOWN arrows.\n At the end, please press Enter.\n If You do not want change amount of tests, just press Enter after close console\n Bigger amount mean more accurate results. \n");Game.DisplayText("How much tests You want? for script You want?");do{Player.CanControlCharacter = false;if (Game.isKeyPressed(Keys.Up)){time_run_limit=time_run_limit+1;Game.DisplayText("Amount of tests ="+time_run_limit);}if (Game.isKeyPressed(Keys.Down)){time_run_limit=time_run_limit-1;if (time_run_limit<1) time_run_limit=1;Game.DisplayText("Amount of tests ="+time_run_limit);}Wait(50);}while (!(Game.isKeyPressed(Keys.Enter)));Player.CanControlCharacter = true;Game.Console.Open();Game.Console.Print("Interval of script is "+interval+" ms");Game.Console.Print("Amount tests of script is "+time_run_limit+"\n");Game.Console.Print("Type here 'nvtest'");} public void TICK_DO_ALL_TIME(object sender, EventArgs e) { if (run_test==true) { if (GTA.Native.Function.Call<int>("TIMERC")<1000) { x=x+1; Wait(interval); } else { Game.DisplayText("Testing speed ..."); getallx[time_run-1]=x; Game.Console.Print("Test "+time_run+" run "+x+" times."); time_run=time_run+1; x=0; GTA.Native.Function.Call("SETTIMERC", 0); if (time_run==(time_run_limit+1)) { for (int xyz=0; xyz<=9; xyz++) { summarum=summarum+getallx[xyz]; } summarum=summarum/time_run_limit; run_test=false; Game.Console.Print("AVG times how much run script: "+Math.Round(summarum,0)+"\nwith interval: "+interval+"\nand with "+time_run_limit+" tests"); Game.DisplayText("Testing script speed STOP"); Game.Console.Open(); } } }}}} Codes allowed in game console: "nvconfig" "nvtest" nvconfig is for set interval and limits tests in game. Interval is it time before script do next loop. Second option, limit of tests, allow to user make very accurace test. Bigger value give more precise results. nvtest - make test. When test run, You can do anything. Also play with others scripts. Instructions: This scripts generaly is for developers, but also normal user can use this like benchmark for scripts. If interval is 0 and You have big amount of AVG it is good. If Your AVG amount is under 20 - Your computer must really work hard now. Try to disable some programs in Windows and run again this test. Better? Please write here. Developer on this script, can see what is difference for computer if interval is not set to 1 or 2... Why i say this? Because in GTA 4, many programmist think everyone super computer. Why script must check every milisecond what we do? For me, 10 scripts running and added "this.Interval = 1" make my game run faster... Only 1 ms for every script... So, with my script You can see in different locations, situations how many loops do script. Your script also should do same amount of loops. I just left for You to fun. Small, fast benchmark Forgot, my results [5 AVG for one situation]: Small window, the lowest graphic, interval 0, place near house: 26, 25, 24,26,25 Fullscreen, medium graphic, interval 0, that same place: 15,16,17,16,16 Fullscreen, medium graphic, interval 1, that same place: 16,16,16,15,14 1 loop less, for simple x=x+1 script... what should if You put there some more diffucult things to do? I do not have time for this now, but test for Yourself DateTime start = DateTime.Now; //do stuff DateTime end = DateTime.Now; string Duration = (end - start).seconds.ToString(); ? Actually: using System.Diagnostics;Stopwatch sw = new Stopwatch();sw.Start();... do your stuff ...sw.Stop();TimeSpan executionTime = sw.Elapsed; It's the suggested way by Microsoft. It should have negligible delay. And, just to remind, you should make multiple benchmarks. http://msdn.microsoft.com/en-us/library/sy....stopwatch.aspx Edited July 8, 2013 by pedro2555 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now