Oh, I think I indirectly found a way to access the functions, take a look in the attachments.
If that is what I think it is, then CvPlayer::calculateScore takes 6 ms to run with PPIO+Python call.
Have you concluded your involvement in this analysis?
Are you certain my python code is faster than the current dll code? If you are, I will add my code to the SVN, and you can follow up by removing the dll score calculation code and un-comment the python call.
Example of a good way to measure code performance (that may work without any altercations, I'm not too sure about the logging code I added):
int CvPlayer::calculateScore(bool bFinal, bool bVictory) const
{
PROFILE_FUNC();
if (!isAlive())
{
return 0;
}
if (GET_TEAM(getTeam()).getNumMembers() == 0)
{
return 0;
}
XMLPlatformUtils::Initialize() \\ This seems necessary from the other code I looked at.
unsigned long duration;
// Measure python performance
unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
long lScore = 0;
CyArgsList argsList;
argsList.add((int) getID());
argsList.add(bFinal);
argsList.add(bVictory);
PYTHON_CALL_FUNCTION(__FUNCTION__, PYGameModule, "calculateScore", argsList.makeFunctionArgs(), &lScore);
lScore = (int)lScore
// return ((int)lScore); // commented out because we want the rest of the code here to run.
unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
duration = endMillis - startMillis;
// Python performance measured.
// log result. Could you perhaps look at the variable value for duration in VS at this point?
TCHAR szOut[2048];
sprintf(szOut, "Dll duration: %d ms.\n", duration);
gDLL->logMsg("Test.log", szOut);
// Measure dll performance
startMillis = XMLPlatformUtils::getCurrentMillis();
int iPopulationScore = getScoreComponent(getPopScore(), GC.getGameINLINE().getInitPopulation(), GC.getGameINLINE().getMaxPopulation(), GC.getSCORE_POPULATION_FACTOR(), true, bFinal, bVictory);
int iLandScore = getScoreComponent(getLandScore(), GC.getGameINLINE().getInitLand(), GC.getGameINLINE().getMaxLand(), GC.getSCORE_LAND_FACTOR(), true, bFinal, bVictory);
int iTechScore = getScoreComponent(getTechScore(), GC.getGameINLINE().getInitTech(), GC.getGameINLINE().getMaxTech(), GC.getSCORE_TECH_FACTOR(), true, bFinal, bVictory);
int iWondersScore = getScoreComponent(getWondersScore(), GC.getGameINLINE().getInitWonders(), GC.getGameINLINE().getMaxWonders(), GC.getSCORE_WONDER_FACTOR(), false, bFinal, bVictory);
lScore = iPopulationScore + iLandScore + iTechScore + iWondersScore; // include what is in the return statement even though it wouldn't take any time at all really.
endMillis = XMLPlatformUtils::getCurrentMillis();
duration = endMillis - startMillis;
// dll performance measured.
// log result. Could you perhaps look at the variable value for duration in VS at this point?
sprintf(szOut, "Dll duration: %d ms.", duration);
gDLL->logMsg("Test.log", szOut);
XMLPlatformUtils::Terminate(); \\ This seems necessary from the other code I looked at.
return iPopulationScore + iLandScore + iTechScore + iWondersScore;
}
Bold text is what differs from the current code, excluding the un-commenting of the python call.