Skip to content

Commit

Permalink
Add profiling code for asset callback
Browse files Browse the repository at this point in the history
Measure how long it takes for an asset to be added.
  • Loading branch information
Mauler125 committed Dec 9, 2024
1 parent 0089b03 commit c2fc376
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/assets/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,6 @@ void Assets::AddMaterialAsset_v12(CPakFile* const pak, const char* const assetPa

pak->PushAsset(asset);

Log("\n");

delete matlAsset;
}

Expand Down Expand Up @@ -841,7 +839,5 @@ void Assets::AddMaterialAsset_v15(CPakFile* const pak, const char* const assetPa

pak->PushAsset(asset);

Log("\n");

delete matlAsset;
}
2 changes: 0 additions & 2 deletions src/assets/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ static void Shader_InternalAddShader(CPakFile* const pak, const char* const asse
asset.remainingDependencyCount = 1;

pak->PushAsset(asset);

printf("\n");
}

void Assets::AddShaderAsset_v8(CPakFile* const pak, const char* const assetPath, const rapidjson::Value& mapEntry)
Expand Down
2 changes: 0 additions & 2 deletions src/assets/shaderset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ void ShaderSet_CreateSet(CPakFile* const pak, const char* const assetPath, const

asset.AddGuids(&guids);
pak->PushAsset(asset);

printf("\n");
}

// TODO:
Expand Down
1 change: 0 additions & 1 deletion src/assets/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ void Assets::AddTextureAsset(CPakFile* const pak, const PakGuid_t guidOverride,
pak->PushAsset(asset);

input.Close();
printf("\n");
}

void Assets::AddTextureAsset_v8(CPakFile* const pak, const char* const assetPath, const rapidjson::Value& mapEntry)
Expand Down
6 changes: 6 additions & 0 deletions src/logic/pakfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ bool CPakFile::AddJSONAsset(const char* const targetType, const char* const asse
if (targetFunc)
{
Log("Adding %s asset \"%s\".\n", assetType, assetPath);

const steady_clock::time_point start = high_resolution_clock::now();
targetFunc(this, assetPath, file);
const steady_clock::time_point stop = high_resolution_clock::now();

const microseconds duration = duration_cast<microseconds>(stop - start);
Log("...done; took %lld ms.\n", duration.count());
}
else
Warning("Asset type '%.4s' is not supported on RPak version %hu.\n", assetType, fileVersion);
Expand Down

0 comments on commit c2fc376

Please sign in to comment.