Example #1
0
/* ARGSUSED1 */
static void keyboard (unsigned char key, int x, int y)
{
   switch (key) {
      case 't':
         if (tdist < 4.0) {
            tdist = (tdist + 0.5);
            glutPostRedisplay();
         }
         break;
      case 'T':
         if (tdist > -5.0) {
            tdist = (tdist - 0.5);
            glutPostRedisplay();
         }
         break;
      case 'F':
         polyfactor = polyfactor + 0.1;
	 printf ("polyfactor is %f\n", polyfactor);
         glutPostRedisplay();
         break;
      case 'f':
         polyfactor = polyfactor - 0.1;
	 printf ("polyfactor is %f\n", polyfactor);
         glutPostRedisplay();
         break;
      case 'U':
         polyunits = polyunits + 1.0;
	 printf ("polyunits is %f\n", polyunits);
         glutPostRedisplay();
         break;
      case 'u':
         polyunits = polyunits - 1.0;
	 printf ("polyunits is %f\n", polyunits);
         glutPostRedisplay();
         break;
      case 'b':
	 Benchmark(5.0, 0);
	 break;
      case 'B':
	 Benchmark(0, 5.0);
	 break;
      case ' ':
	 fill = !fill;
	 printf ("fill/line: %d\n", fill);
         glutPostRedisplay();
         break;
      case 27:  /* Escape */
         exit(0);
         break;
      default:
         break;
   }
   fflush(stdout);
}
Example #2
0
void main() {
    debug();
    Describe("RGBAImage<byte>", []() {
        It("should be able to read data from bmp file", []() {
            RGBAImage<byte> image("TestResources/rgbw_2x2.bmp");
            Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(255, 0, 0, 255));
            Expect(image.GetPixel(1, 0)).ToBe(RGBAColor<byte>(0, 255, 0, 255));
            Expect(image.GetPixel(0, 1)).ToBe(RGBAColor<byte>(0, 0, 255, 255));
            Expect(image.GetPixel(1, 1)).ToBe(RGBAColor<byte>(255, 255, 255, 255));
        });
        Describe("when read lena.bmp finished", []() {
            RGBAImage<byte> image("TestResources/Lena.bmp");
            It("should be able to get width and height", [&image]() {
                Expect(image.Height()).ToBe(512);
                Expect(image.Width()).ToBe(512);
            });
            It("should be able to get pixel", [&image]() {
                Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(225, 138, 128, 255));
            });
            It("should be able to indexof sub image", [&image]() {
                RGBAImage<byte> sub1("TestResources/IndexOf/sub1.bmp");
                RGBAImage<byte> sub2("TestResources/IndexOf/sub2.bmp");
                RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp");
                Expect(image.IndexOf(sub1)).ToBe(Coord<short>(0, 0));
                Expect(image.IndexOf(sub2)).ToBe(Coord<short>(1, 500));
                Expect(image.IndexOf(sub3)).ToBe(Coord<short>(122, 237));
            });
        });
    });
    Benchmark("read lene.bmp", []() {
        RGBAImage<byte> image("TestResources/Lena.bmp");
    });
    Benchmark("indexof lene.bmp", []() {
        RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp");
        RGBAImage<byte> image("TestResources/Lena.bmp");
        image.IndexOf(sub3);
    });
}
Example #3
0
int main(int argc, char** argv)
{
	{
		Poco::NullMutex mtx;
		Benchmark(mtx, "NullMutex");
	}

	{
		Poco::Mutex mtx(Poco::Mutex::MUTEX_RECURSIVE);
		Benchmark(mtx, "Mutex(MUTEX_RECURSIVE)");
	}

	{
		Poco::Mutex mtx(Poco::Mutex::MUTEX_NONRECURSIVE);
		Benchmark(mtx, "Mutex(MUTEX_NONRECURSIVE)");
	}

	{
		Poco::FastMutex mtx;
		Benchmark(mtx, "FastMutex");
	}

	return 0;
}
Example #4
0
void BenchmarkWithCommand(int argc, const char* const argv[])
{
	std::string command(argv[1]);
	float runningTime(argc >= 3 ? Test::StringToValue<float, true>(argv[2]) : 1.0f);
	float cpuFreq(argc >= 4 ? Test::StringToValue<float, true>(argv[3])*float(1e9) : 0.0f);
	std::string algoName(argc >= 5 ? argv[4] : "");

	if (command == "b")  // All benchmarks
		Benchmark(Test::All, runningTime, cpuFreq);
	else if (command == "b3")  // Public key algorithms
		Test::Benchmark(Test::PublicKey, runningTime, cpuFreq);
	else if (command == "b2")  // Shared key algorithms
		Test::Benchmark(Test::SharedKey, runningTime, cpuFreq);
	else if (command == "b1")  // Unkeyed algorithms
		Test::Benchmark(Test::Unkeyed, runningTime, cpuFreq);
}
Example #5
0
HRESULT Benchmark()
{
  HRESULT result;
  MY_TRY_BEGIN
  CREATE_CODECS

  #ifdef EXTERNAL_CODECS
  CObjectVector<CCodecInfoEx> externalCodecs;
  RINOK(LoadExternalCodecs(codecs, externalCodecs));
  #endif
  result = Benchmark(
      #ifdef EXTERNAL_CODECS
      codecs, &externalCodecs,
      #endif
      (UInt32)-1, (UInt32)-1, g_HWND);
  MY_TRY_FINISH
  return result;
}
int main(int argc, char **argv)
{
    if (argc < 4)
    {
        std::cout << "./rtree-bench file.ramIndex file.fileIndx file.nodes"
                  << "\n";
        return 1;
    }

    const char *ramPath = argv[1];
    const char *filePath = argv[2];
    const char *nodesPath = argv[3];

    auto coords = LoadCoordinates(nodesPath);

    BenchStaticRTree rtree(ramPath, filePath, coords);

    Benchmark(rtree, 10000);

    return 0;
}
void PulseService(bool Broadcast, unsigned int MSG, void *lpData)
{
    if (MSG == PULSE_PULSE) {
        if (GetGameState() == GAMESTATE_CHARSELECT && !MQChatWnd) {
            CreateChatWindow();
        }
        if (MQChatWnd && PendingChatLines) {
            bool doscroll = (((CXWnd*)MQChatWnd->OutputBox)->VScrollPos == (MQChatWnd->OutputBox->VScrollMax));

            DWORD ThisPulse = PendingChatLines;
            if (ThisPulse > LINES_PER_FRAME) {
                ThisPulse = LINES_PER_FRAME;
            }
            PendingChatLines -= ThisPulse;
            MQChatWnd->OutBoxLines += ThisPulse;

            if (MQChatWnd->OutBoxLines > MAX_CHAT_SIZE) {
                DWORD Diff = (MQChatWnd->OutBoxLines - MAX_CHAT_SIZE) + LINES_PER_FRAME;
                MQChatWnd->OutBoxLines -= Diff;
                Benchmark(bmStripFirstStmlLines, MQChatWnd->OutputBox->StripFirstSTMLLines(Diff));
            }
            for (DWORD N = 0 ; N < ThisPulse ; N++) {
                DebugTry(MQChatWnd->OutputBox->AppendSTML( pPendingChat->Text));
                ChatBuffer *pNext = pPendingChat->pNext;
                delete pPendingChat;
                pPendingChat = pNext;
            }
            if (!pPendingChat) {
                pPendingChatTail = 0;
            }
            if (doscroll || MQChatWnd->AutoScroll) {
                DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(MQChatWnd->OutputBox->VScrollMax));
            }
        }
    }
}
Example #8
0
void Pulse()
{
	if (!ppCharSpawn || !pCharSpawn) return;
	PSPAWNINFO pCharOrMount = NULL;
	PCHARINFO pCharInfo = GetCharInfo();
	PSPAWNINFO pChar = pCharOrMount = (PSPAWNINFO)pCharSpawn;
	if (pCharInfo && pCharInfo->pSpawn) pChar = pCharInfo->pSpawn;

	static WORD LastZone = -1;

	static PSPAWNINFO pCharOld = NULL;
	static FLOAT LastX = 0.0f;
	static FLOAT LastY = 0.0f;
	static ULONGLONG LastMoveTick = 0;
	static DWORD MapDelay = 0;

	static DWORD LastHealth = 0;
	static DWORD LastMana = 0;
	static DWORD LastEndurance = 0;



	// Drop out here if we're waiting for something.
	if (!pChar || gZoning /* || gDelayZoning*/) return;
	if (!pCharInfo) {
		//DebugSpew("Pulse: no charinfo returning\n");
		return;
	}

	if ((unsigned int)GetCharInfo()->charinfo_info & 0x80000000) return;

	if (pChar != pCharOld && WereWeZoning)
	{
		WereWeZoning = FALSE;
		pCharOld = pChar;
		gFaceAngle = 10000.0f;
		gLookAngle = 10000.0f;
		gbMoving = FALSE;
		LastX = pChar->X;
		LastY = pChar->Y;
		LastMoveTick = MQGetTickCount64();
		EnviroTarget.Name[0] = 0;
		pGroundTarget = 0;
		DoorEnviroTarget.Name[0] = 0;
		pDoorTarget = 0;
		LastHealth = GetCurHPS();
		LastMana = GetCharInfo2()->Mana;
		LastEndurance = GetCharInfo2()->Endurance;
		ManaGained = 0;
		HealthGained = 0;
		EnduranceGained = 0;
		// see if we're on a pvp server
		if (!_strnicmp(EQADDR_SERVERNAME, "tallon", 6) || !_strnicmp(EQADDR_SERVERNAME, "vallon", 6))
		{
			PVPServer = PVP_TEAM;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "sullon", 6))
		{
			PVPServer = PVP_SULLON;
		}
		else if (!_strnicmp(EQADDR_SERVERNAME, "rallos", 6))
		{
			PVPServer = PVP_RALLOS;
		}
		else
			PVPServer = PVP_NONE;
		srand((unsigned int)time(NULL) + (unsigned int)GetCurrentProcessId()); // reseed
		Benchmark(bmPluginsOnZoned, PluginsZoned());

	}
	else if ((LastX != pChar->X) || (LastY != pChar->Y) || LastMoveTick>MQGetTickCount64() - 100) {
		if ((LastX != pChar->X) || (LastY != pChar->Y)) LastMoveTick = MQGetTickCount64();
		gbMoving = TRUE;
		LastX = pChar->X;
		LastY = pChar->Y;
	}
	else {
		gbMoving = FALSE;
	}

	DWORD CurrentHealth = GetCurHPS();
	if (LastHealth && CurrentHealth>LastHealth)
	{
		if ((int)pChar->HPCurrent != GetMaxHPS())
		{ // gained health, and not max
			HealthGained = CurrentHealth - LastHealth;
		}
	}
	LastHealth = CurrentHealth;

	if (LastMana && GetCharInfo2()->Mana > LastMana)
	{
		if ((int)GetCharInfo2()->Mana - LastMana > 0)
		{
			ManaGained = GetCharInfo2()->Mana - LastMana;
		}
	}
	LastMana = GetCharInfo2()->Mana;

	if (LastEndurance && GetCharInfo2()->Endurance > LastEndurance)
	{
		if (GetCharInfo2()->Endurance != GetMaxEndurance())
		{
			EnduranceGained = GetCharInfo2()->Endurance - LastEndurance;
		}
	}
	LastEndurance = GetCharInfo2()->Endurance;

	if (gbDoAutoRun && pChar && pCharInfo) {
		gbDoAutoRun = FALSE;
#ifndef EMU
		InitKeyRings();
#endif
		CHAR szServerAndName[MAX_STRING] = { 0 };
		CHAR szAutoRun[MAX_STRING] = { 0 };
		PCHAR pAutoRun = szAutoRun;
		/* autorun for everyone */
		GetPrivateProfileString("AutoRun", "ALL", "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
		/* autorun for toon */
		ZeroMemory(szAutoRun, MAX_STRING); pAutoRun = szAutoRun;
		sprintf(szServerAndName, "%s.%s", EQADDR_SERVERNAME, pCharInfo->Name);
		GetPrivateProfileString("AutoRun", szServerAndName, "", szAutoRun, MAX_STRING, gszINIFilename);
		while (pAutoRun[0] == ' ' || pAutoRun[0] == '\t') pAutoRun++;
		if (szAutoRun[0] != 0) DoCommand(pChar, pAutoRun);
	}

	if ((gFaceAngle != 10000.0f) || (gLookAngle != 10000.0f)) {
		TurnNotDone = FALSE;
		if (gFaceAngle != 10000.0f) {
			if (abs((INT)(pCharOrMount->Heading - gFaceAngle)) < 10.0f) {
				pCharOrMount->Heading = (FLOAT)gFaceAngle;
				pCharOrMount->SpeedHeading = 0.0f;
				gFaceAngle = 10000.0f;
			}
			else {
				TurnNotDone = TRUE;
				DOUBLE c1 = pCharOrMount->Heading + 256.0f;
				DOUBLE c2 = gFaceAngle;
				if (c2<pChar->Heading) c2 += 512.0f;
				DOUBLE turn = (DOUBLE)(rand() % 200) / 10;
				if (c2<c1) {
					pCharOrMount->Heading += (FLOAT)turn;
					pCharOrMount->SpeedHeading = 12.0f;
					if (pCharOrMount->Heading >= 512.0f) pCharOrMount->Heading -= 512.0f;
				}
				else {
					pCharOrMount->Heading -= (FLOAT)turn;
					pCharOrMount->SpeedHeading = -12.0f;
					if (pCharOrMount->Heading<0.0f) pCharOrMount->Heading += 512.0f;
				}
			}
		}

		if (gLookAngle != 10000.0f) {
			if (abs((INT)(pChar->CameraAngle - gLookAngle)) < 5.0f) {
				pChar->CameraAngle = (FLOAT)gLookAngle;
				gLookAngle = 10000.0f;
				TurnNotDone = FALSE;
			}
			else {
				TurnNotDone = TRUE;
				FLOAT c1 = pChar->CameraAngle;
				FLOAT c2 = (FLOAT)gLookAngle;

				DOUBLE turn = (DOUBLE)(rand() % 200) / 20;
				if (c1<c2) {
					pChar->CameraAngle += (FLOAT)turn;
					if (pChar->CameraAngle >= 128.0f) pChar->CameraAngle -= 128.0f;
				}
				else {
					pChar->CameraAngle -= (FLOAT)turn;
					if (pChar->CameraAngle <= -128.0f) pChar->CameraAngle += 128.0f;
				}
			}
		}

		if (TurnNotDone) {
			bRunNextCommand = FALSE;
			IsMouseWaiting();
			return;
		}
	}
}
Example #9
0
	VOID SetGameState_Detour(DWORD GameState)
	{
		//        DebugSpew("SetGameState_Detour(%d)",GameState);
		SetGameState_Trampoline(GameState);
		Benchmark(bmPluginsSetGameState, PluginsSetGameState(GameState));
	}
Example #10
0
void Heartbeat()
{
	if (gbUnload)
		return;
	static ULONGLONG LastGetTick = 0;
	static bool bFirstHeartBeat = true;
	static ULONGLONG TickDiff = 0;
	static fMQPulse pEQPlayNicePulse = NULL;
	static DWORD BeatCount = 0;

	ULONGLONG Tick = MQGetTickCount64();

	BeatCount++;

	if (bFirstHeartBeat)
	{
		LastGetTick = Tick;
		bFirstHeartBeat = false;
	}
	// This accounts for rollover
	TickDiff += (Tick - LastGetTick);
	LastGetTick = Tick;
#ifndef ISXEQ
	while (TickDiff >= 100) {
		TickDiff -= 100;
		if (gDelay>0) gDelay--;
		DropTimers();
	}
#endif
	if (!gStringTableFixed && pStringTable) // Please dont remove the second condition
	{
		FixStringTable();
		gStringTableFixed = TRUE;
	}

	DebugTry(int GameState = GetGameState());
	if (GameState != -1)
	{
		if ((DWORD)GameState != gGameState)
		{
			DebugSpew("GetGameState()=%d vs %d", GameState, gGameState);
			gGameState = GameState;
			DebugTry(Benchmark(bmPluginsSetGameState, PluginsSetGameState(GameState)));
		}
	}
	else
		return;
	DebugTry(UpdateMQ2SpawnSort());
#ifndef ISXEQ_LEGACY
#ifndef ISXEQ
	DebugTry(DrawHUD());
	//if (gGameState==GAMESTATE_INGAME && !bMouseLook && ScreenMode==3)
	//{
	//    DebugTry(pWndMgr->DrawCursor());
	//}
#endif
#endif

	bRunNextCommand = TRUE;
	DebugTry(Pulse());
#ifndef ISXEQ_LEGACY
#ifndef ISXEQ
	DebugTry(Benchmark(bmPluginsPulse, DebugTry(PulsePlugins())));
#endif
	if (pEQPlayNicePulse) {
		pEQPlayNicePulse();
	}
	else {
		HMODULE hmEQPlayNice;
		if (((BeatCount % 63) == 0) && (hmEQPlayNice = GetModuleHandle("EQPlayNice.dll"))) {
			if (pEQPlayNicePulse = (fMQPulse)GetProcAddress(hmEQPlayNice, "Compat_ProcessFrame"))
				pEQPlayNicePulse();
		}
	}
#endif
	DebugTry(ProcessPendingGroundItems());


	static bool ShownNews = false;
	if (gGameState == GAMESTATE_CHARSELECT && !ShownNews)
	{
		ShownNews = true;
		if (gCreateMQ2NewsWindow)
			CreateMQ2NewsWindow();
	}

#ifndef ISXEQ
	DWORD CurTurbo = 0;

	if (gDelayedCommands)
	{// delayed commands
		lockit lk(ghLockDelayCommand);
		DoCommand((PSPAWNINFO)pLocalPlayer, gDelayedCommands->szText);
		PCHATBUF pNext = gDelayedCommands->pNext;
		LocalFree(gDelayedCommands);
		gDelayedCommands = pNext;
	}
	while (bRunNextCommand) {
		if (!DoNextCommand()) break;
		if (!gTurbo) break;//bRunNextCommand = FALSE;
		if (++CurTurbo>gMaxTurbo) break;//bRunNextCommand =   FALSE;
	}
	DoTimedCommands();
#endif
}
int main(int argc, char* argv[]) {
  // benchmark graph creation
  int OneK = 1000;
  int NodeArr[5];
  int EdgeArr[3];
  int i = 0;
  int j = 0;
  int k = 0;
  int TenP = 1;
  int NNodes = 0;
  int NEdges = 0;
  int msec = 0;
  PNGraph G1;
  PUNGraph G2;
  PNEGraph G3;
  PNEAGraph G4;

  std::ofstream file;

  for (i = 0; i < 5; i++) {
    TenP *= 10;
    NodeArr[i] = TenP * OneK;
  } 
  EdgeArr[0] = 10;
  EdgeArr[1] = 50;
  EdgeArr[2] = 100;
  
  for (k = 0; k < 4; k++) {
    printf("Starting Benchmarking for ");
    switch (k) {
    case 0:
      file.open("tngraph.dat");
      printf("TNGraph\n\n");
      break;
    case 1:
      file.open("tungraph.dat");
      printf("TUNGraph\n\n");
      break;
    case 2:
      file.open("tnegraph.dat");
      printf("TNEGraph\n\n");
      break;
    default:
      file.open("tneagraph.dat");
      printf("TNEAGraph\n\n");
      break;
    }

    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; j++) {
	clock_t start = clock();
	NNodes = NodeArr[i];
	NEdges = EdgeArr[j]*NodeArr[i];
	switch (k) {
      case 0:
	printf("\nGenerating Graph...\n");
	printf("GrGen ");
	G1 = GenRndGnm<PNGraph>(NNodes, NEdges, true);
	msec = (clock() - start) * 1000 / CLOCKS_PER_SEC;
	printf("Nodes: %d Edges: %d Time: %d ms\n", NNodes, NEdges, msec);
        file << NNodes << " " << NEdges << " " << msec << " ";
	Benchmark(G1, file);
	printf("Defragmenting...\n");
	G1->Defrag();
	Benchmark(G1, file);
	G1->Clr();
	break;
      case 1:
	printf("\nGenerating Graph...\n");
	printf("GrGen ");
	G2 = GenRndGnm<PUNGraph>(NNodes, NEdges, false);
	msec = (clock() - start) * 1000 / CLOCKS_PER_SEC;
	printf("Nodes: %d Edges: %d Time: %d ms\n", NNodes, NEdges, msec);
        file << NNodes << " " << NEdges << " " << msec << " ";
	Benchmark(G2, file);    
	printf("Defragmenting...\n");
	G2->Defrag();
	Benchmark(G2, file);
	G2->Clr();
	break;
      case 2:
	printf("\nGenerating Graph...\n");
	printf("GrGen ");
	G3 = GenRndGnm<PNEGraph>(NNodes, NEdges, true);
	msec = (clock() - start) * 1000 / CLOCKS_PER_SEC;
	printf("Nodes: %d Edges: %d Time: %d ms\n", NNodes, NEdges, msec);
        file << NNodes << " " << NEdges << " " << msec << " ";
	Benchmark(G3, file);    
	printf("Defragmenting...\n");
	G3->Defrag();
	Benchmark(G3, file);
	G3->Clr();
	break;
      default:
	printf("\nGenerating Graph...\n");
	printf("GrGen ");
	G4 = GenRndGnm<PNEAGraph>(NNodes, NEdges, true);
	msec = (clock() - start) * 1000 / CLOCKS_PER_SEC;
	printf("Nodes: %d Edges: %d Time: %d ms\n", NNodes, NEdges, msec);
        file << NNodes << " " << NEdges << " " << msec << " ";
	Benchmark(G4, file);    
	printf("Defragmenting...\n");
	G4->Defrag();
	Benchmark(G4, file);
	G4->Clr();
	break;
	}
        file << "\n";
      }
    }
    
    file.close();
  }
}
Example #12
0
static void Key( unsigned char key, int x, int y )
{
   (void) x;
   (void) y;
   switch (key) {
   case 27:
      exit(0);
   case 'f':
      ModeMenu((state ^ FOG_MASK) & FOG_MASK);
      break;
   case 's':
      ModeMenu((state ^ SHADE_MASK) & SHADE_MASK);
      break;
   case 't':
      ModeMenu((state ^ STIPPLE_MASK) & STIPPLE_MASK);
      break;
   case 'l':
      ModeMenu((state ^ LIGHT_MASK) & (LIT|UNLIT));
      break;
   case 'm':
      ModeMenu((state ^ MATERIAL_MASK) & MATERIAL_MASK);
      break;
   case 'c':
      ModeMenu((state ^ CLIP_MASK) & CLIP_MASK);
      break;
   case 'v':
      ModeMenu((LOCKED|IMMEDIATE|DRAW_ELTS|TRIANGLES) & allowed);
      break;
   case 'V':
      ModeMenu(UNLOCKED|IMMEDIATE|GLVERTEX|STRIPS);
      break;
   case 'b':
      Benchmark(5.0, 0);
      break;
   case 'B':
      Benchmark(0, 5.0);
      break;
   case 'i':
      dist += .25;
      set_matrix();
      glutPostRedisplay();
      break;
   case 'I':
      dist -= .25;
      set_matrix();
      glutPostRedisplay();
      break;
   case '-':
   case '_':
      plane[3] += 2.0;
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glClipPlane(GL_CLIP_PLANE0, plane);
      set_matrix();
      glutPostRedisplay();
      break;
   case '+':
   case '=':
      plane[3] -= 2.0;
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glClipPlane(GL_CLIP_PLANE0, plane);
      set_matrix();
      glutPostRedisplay();
      break;
   case ' ':
      Init(0,0);
      break;
   }
}
Example #13
0
PLUGIN_API VOID OnPulse() 
{ 
    if (gGameState==GAMESTATE_CHARSELECT && !MQChatWnd && !bNoCharSelect) 
    { 
        CreateChatWindow(); 
    } 
	//if (CXWnd *krwnd = FindMQ2Window("TaskOverlayWnd")) {
	//	Sleep(0);
	//}
    if (MQChatWnd) 
    { 
		switch (gGameState)
		{
			case GAMESTATE_CHARSELECT: 
			{
				if (MQChatWnd->ZLayer != 1)
					MQChatWnd->ZLayer = 1;
				break;
			}
			case GAMESTATE_INGAME:
			{
				if (MQChatWnd->ZLayer != 0)
					MQChatWnd->ZLayer = 0;
				break;
			} 
		}
        if(PendingChatLines) 
        { 
            // set 'old' to current 
            ulOldVScrollPos=MQChatWnd->OutputBox->VScrollPos; 

            // scroll down if autoscroll enabled, or current position is the bottom of chatwnd 
            bool bScrollDown=bAutoScroll?true:(MQChatWnd->OutputBox->VScrollPos==MQChatWnd->OutputBox->VScrollMax?true:false); 

            DWORD ThisPulse=PendingChatLines; 
            if (ThisPulse>LINES_PER_FRAME) 
            { 
                ThisPulse=LINES_PER_FRAME; 
            } 
            PendingChatLines-=ThisPulse; 
            MQChatWnd->OutBoxLines+=ThisPulse; 
            if (MQChatWnd->OutBoxLines>MAX_CHAT_SIZE) 
            { 
                DWORD Diff=(MQChatWnd->OutBoxLines-MAX_CHAT_SIZE)+LINES_PER_FRAME; 
                MQChatWnd->OutBoxLines-=Diff; 
                Benchmark(bmStripFirstStmlLines,MQChatWnd->OutputBox->StripFirstSTMLLines(Diff)); 
            } 
            for (DWORD N=0 ; N<ThisPulse ; N++) 
            {
				if(pPendingChat) {
					DebugTry(MQChatWnd->OutputBox->AppendSTML(pPendingChat->Text)); 
					ChatBuffer *pNext=pPendingChat->pNext; 
					delete pPendingChat; 
					pPendingChat=pNext; 
				}
                //DebugSpew("NEW: max %u - pos: %u",MQChatWnd->OutputBox->VScrollMax,MQChatWnd->OutputBox->VScrollPos); 
            } 
            if (!pPendingChat) 
            { 
                pPendingChatTail=0; 
            } 

            if(bScrollDown) 
            { 
                // set current vscroll position to bottom 
                DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(MQChatWnd->OutputBox->VScrollMax)); 
            } 
            else 
            { 
                // autoscroll is disabled and current vscroll position was not at the bottom, retain position 
                // note: if the window is full (VScrollMax value between 9793 and 9835), this will not adjust with 
                // the flushing of buffer that keeps window a certain max size 
                DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(ulOldVScrollPos)); 
            } 
        } 

        if(InHoverState()) 
        { 
            ((CXWnd*)MQChatWnd)->DoAllDrawing(); 
        } 
    } 
} 
Example #14
0
#include "../test_helper.h"
#include "../../src/sorting/sorting.h"

Benchmark BM = Benchmark();
const int _1000 = 1000;
const int _10000 = 10000;
const int _100000 = 100000;
const int _1000000 = 1000000;
const int _64000000 = 64000000;

void test_sorter(__sorter sorter, void * const start, void * const end,
		size_t size, __comporator cmp) {
	BM.start();
	(sorter)(start, end, size, cmp);
	cout << BM.getTime() << "\t";
	EXPECT_TRUE(isSorted(start, end,size,cmp));
}

void reverse_test_int_sorter(size_t size, __sorter sorter) {
	int* array = craeteInverseArray(size);
	test_sorter(sorter, array, array + size, _INT, intComporator);
	free(array);
}

void reverse_test_int_sorter(string name, __sorter sorter) {
	cout << "[ NAME     ] " << name << endl;
	cout << "[ TIME     ] ";

	reverse_test_int_sorter(_1000, sorter);
	reverse_test_int_sorter(_10000, sorter);
	reverse_test_int_sorter(_100000, sorter);
Example #15
0
int main(int argc, char* argv[]) {
    // const unsigned int argon2_type_length = 10;

    unsigned char out[32];

    uint32_t outlen = 32;
    uint32_t m_cost = 1 << 18;
    uint32_t t_cost = 3;
    uint32_t p_len = 16;
    unsigned thread_n = 4;
    uint32_t s_len = 16;

    bool generate_test_vectors = false;
    //char type[argon2_type_length] = "Argon2d";
    std::string type;

#ifdef KAT
    remove(KAT_FILENAME);
#endif

    if (argc == 1) {
        GenKat();
        return 0;
    }

    for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-help") == 0) {
            printf("====================================== \n");
            printf("Argon2 - test implementation \n");
            printf("====================================== \n");
            printf("Options:\n");
            printf("\t -taglength <Tag Length: 0..31>\n");
            printf("\t -logmcost < Base 2 logarithm of m_cost : 0..23 > \n");
            printf("\t -tcost < t_cost : 0..2^24 > \n");
            printf("\t -pwdlen < Password : length>\n");
            printf("\t -saltlen < Salt : Length>\n");
            printf("\t -threads < Number of threads : % d.. % d>\n", MIN_LANES, MAX_LANES);
            printf("\t -type <Argon2d; Argon2di; Argon2ds; Argon2i; Argon2id >\n");
            printf("\t -gen-tv\n");
            printf("\t -verify\n");
            printf("\t -benchmark\n");
            printf("\t -help\n");
            printf("If no arguments given, Argon2 is called with default parameters t_cost=%d, m_cost=%d and threads=%d.\n", t_cost, m_cost, thread_n);
            return 0;
        }

        if (strcmp(argv[i], "-taglength") == 0) {
            if (i < argc - 1) {
                i++;
                outlen = atoi(argv[i]) % 32;
                continue;
            }
        }

        if (strcmp(argv[i], "-logmcost") == 0) {
            if (i < argc - 1) {
                i++;
                m_cost = (size_t) 1 << (atoi(argv[i]) % 24);
                continue;
            }
        }

        if (strcmp(argv[i], "-tcost") == 0) {
            if (i < argc - 1) {
                i++;
                t_cost = atoi(argv[i]) & 0xffffff;
                continue;
            }
        }

        if (strcmp(argv[i], "-pwdlen") == 0) {
            if (i < argc - 1) {
                i++;
                p_len = atoi(argv[i]) % 160;
                continue;
            }
        }

        if (strcmp(argv[i], "-saltlen") == 0) {
            if (i < argc - 1) {
                i++;
                s_len = atoi(argv[i]) % 32;
                continue;
            }
        }

        if (strcmp(argv[i], "-threads") == 0) {
            if (i < argc - 1) {
                i++;
                thread_n = atoi(argv[i]) % 32;
                continue;
            }
        }

        if (strcmp(argv[i], "-type") == 0) {
            if (i < argc - 1) {
                i++;
                type = std::string(argv[i]);
                //                      if (argon2_type_length >= strlen(argv[i])) {
                //                   memcpy(type, argv[i], strlen(argv[i]));
                //              }
                continue;
            }
        }

        if (strcmp(argv[i], "-gen-tv") == 0) {
            generate_test_vectors = true;
            continue;
        }

        if (strcmp(argv[i], "-verify") == 0) {
            bool modify = false;
            if (i < argc - 1) {
                i++;
                if (0 != atoi(argv[i])) {
                    modify = true;
                }
            }

            VerifyTest(modify);
            return 0;
        }

        if (strcmp(argv[i], "-benchmark") == 0) {
            Benchmark();
            return 0;
        }
    }

    if (generate_test_vectors) {
        GenerateTestVectors(type);
        return 0;
    }

    Run(out, outlen, p_len, s_len, t_cost, m_cost);

    return 0;
}