02.01.2014, 18:36
(
Последний раз редактировалось Emmet_; 02.01.2014 в 19:48.
)
Benchmark include
Introduction
This include allows the possibility to perform stress tests against specially initialized functions (called benchmarks). You can easily initialize these benchmarks without having to write out loops and compare the results all of the time.
How does it work?
It's simple, download the latest version of YSI here and include it at the top of the script:
After that, you can initialize your own benchmarks:
Please note that these functions can't return values, as it would be very redundant if they could do so anyway.
Initializing benchmarks
Using the example above, you can initialize benchmarks easily:
1000 is the number of times to call the corresponding code. You can also specify parameters!
Performing benchmarks
There are two functions that allows you to perform these benchmarks.
Passing no arguments will run all benchmark functions. You can also pass only the ones you wish to test:
You can also use "Benchmark_RunEx" which allows you to run a benchmark with a custom set time:
It can also accept multiple parameters.
OnBenchPerformed
This include also adds a new special callback:
This callback is called once a benchmark has completed.
Credits
Available at my GitHub page - click here.
The reason I use GitHub now is because it allows me to control my libraries easier and quicker, without having to always delete and upload files.
Introduction
This include allows the possibility to perform stress tests against specially initialized functions (called benchmarks). You can easily initialize these benchmarks without having to write out loops and compare the results all of the time.
How does it work?
It's simple, download the latest version of YSI here and include it at the top of the script:
pawn Код:
#include <benchmarks>
pawn Код:
Benchmark:name[time]() {}
Initializing benchmarks
Using the example above, you can initialize benchmarks easily:
pawn Код:
Benchmark:test[1000]()
{
// Code here...
}
pawn Код:
Benchmark:test[1000](string[128])
{
// Code here...
}
There are two functions that allows you to perform these benchmarks.
pawn Код:
forward Benchmark_Run(...);
pawn Код:
Benchmark_Run("test", "test2");
pawn Код:
// This would run test 10,000 times instead of the defined 1,000.
Benchmark_RunEx("test", 10000);
pawn Код:
Benchmark_RunEx("test", 10000, "test2", 20000);
This include also adds a new special callback:
pawn Код:
public OnBenchPerformed(function[], time)
{
return 1;
}
Credits
- ****** - Inspired by y_timers and y_testing.
- Slice - Inspired by his benchmark macros.
Available at my GitHub page - click here.
The reason I use GitHub now is because it allows me to control my libraries easier and quicker, without having to always delete and upload files.