Take advantage of Multi-Core Processors and Multi-threading
MultiThreading is already in the programs u develop, just behind the scenes. Take advantage of it to improve the performance of those multi-core processors and optimize it for the single thread processors.
example:
This will allow u to do multiple things at a time using multiple threads.The number of threads are limited to the number of logical processor and single thread processors will not see any performance change. Something like this will help u with your menus. The reason menus lag is because of the font. Having to draw every character in every string for every item. For each character in a string, in each items, that is a lot of time wasted in looping, but what if u could do more than one of these at a time.
Example:
Please note that fonts not coded for concurrency may have rendering errors, if requested i will be willing to code a Font class for Concurrency
Depending on the number of logical cores the time it takes to render these times may differ.
example:
Code:
#include <ppl.h>
using namespace Concurrency;
void Hook()
{
parallel_invoke(
[&] {
//Hook Present
},
[&] {
//Hook Endscene
});
);
}
Example:
Please note that fonts not coded for concurrency may have rendering errors, if requested i will be willing to code a Font class for Concurrency
Code:
//This function will return the time it takes to call the function
template <class Function>
__int64 time_call(Function&& f){
__int64 begin = GetTickCount();
f();
return GetTickCount() - begin;
}
void DrawParallel()
{
parallel_for(0, 10, [&] (int i)
{
Font.DrawText(200, 20+ i*15, WHITE, "BLA BLA BLA");
});
}
void DrawSerial()
{
for(int i = 0; i < 10; i++)
{
Font.DrawText(20 , 20 + i*15, WHITE, "BLA BLA BLA");
}
}
void RenderFont()
{
// Draws the time it takes to do these different Draws.
Font.DrawNumber( 200, 10, WHITE, time_call([&] { DrawParallel(); } ));
Font.DrawNumber( 20, 10, WHITE, time_call([&] { DrawSerial(); } ));
}
.







