Skip to content

Commit

Permalink
Use std::chrono to measure time elapsed during WriteMiptex (fixes Get…
Browse files Browse the repository at this point in the history
…TickCount warnings)

#138
  • Loading branch information
SamVanheer committed Mar 16, 2022
1 parent 513fffc commit 7a1279d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions utils/qcsg/textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
****/

#include <chrono>

#include "csg.h"

Expand Down Expand Up @@ -279,12 +280,14 @@ WriteMiptex
*/
void WriteMiptex(void)
{
using clock = std::chrono::high_resolution_clock;

int i, len, texsize, totaltexsize = 0;
byte *data;
dmiptexlump_t *l;
char *path;
char fullpath[1024];
int start;
clock::time_point start;

texdatasize = 0;

Expand All @@ -301,15 +304,15 @@ void WriteMiptex(void)

strcpy(fullpath, path);

start = GetTickCount();
start = clock::now();
{
if (!TEX_InitFromWad (fullpath))
return;
AddAnimatingTextures ();
}
qprintf( "TEX_InitFromWad & AddAnimatingTextures elapsed time = %ldms\n", GetTickCount()-start );
qprintf("TEX_InitFromWad & AddAnimatingTextures elapsed time = %ldms\n", std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start).count());

start = GetTickCount();
start = clock::now();
{
for (i=0; i<nummiptex; i++ )
{
Expand All @@ -322,9 +325,9 @@ void WriteMiptex(void)
}
}
}
qprintf( "FindTextures elapsed time = %ldms\n", GetTickCount()-start );
qprintf("FindTextures elapsed time = %ldms\n", std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start).count());

start = GetTickCount();
start = clock::now();
{
int i;
texinfo_t *tx = texinfo;
Expand All @@ -342,9 +345,9 @@ void WriteMiptex(void)
free( miptex_name );
}
}
qprintf( "qsort(miptex) elapsed time = %ldms\n", GetTickCount()-start );
qprintf("qsort(miptex) elapsed time = %ldms\n", std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start).count());

start = GetTickCount();
start = clock::now();
{
// Now setup to get the miptex data (or just the headers if using -wadtextures) from the wadfile
l = (dmiptexlump_t *)dtexdata;
Expand All @@ -368,7 +371,7 @@ void WriteMiptex(void)
}
texdatasize = data - dtexdata;
}
qprintf( "LoadLump() elapsed time = %ldms\n", GetTickCount()-start );
qprintf("LoadLump() elapsed time = %ldms\n", std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start).count());
}

//==========================================================================
Expand Down

0 comments on commit 7a1279d

Please sign in to comment.