MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Finish

Method Finish

src/newgrf_profiling.cpp:110–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110uint32_t NewGRFProfiler::Finish()
111{
112 if (!this->active) return 0;
113
114 if (this->calls.empty()) {
115 IConsolePrint(CC_DEBUG, "Finished profile of NewGRF [{:08X}], no events collected, not writing a file.", std::byteswap(this->grffile->grfid));
116
117 this->Abort();
118 return 0;
119 }
120
121 std::string filename = this->GetOutputFilename();
122 IConsolePrint(CC_DEBUG, "Finished profile of NewGRF [{:08X}], writing {} events to '{}'.", std::byteswap(this->grffile->grfid), this->calls.size(), filename);
123
124 uint32_t total_microseconds = 0;
125
126 auto f = FioFOpenFile(filename, "wt", Subdirectory::NO_DIRECTORY);
127
128 if (!f.has_value()) {
129 IConsolePrint(CC_ERROR, "Failed to open '{}' for writing.", filename);
130 } else {
131 fmt::print(*f, "Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n");
132 for (const Call &c : this->calls) {
133 fmt::print(*f, "{},{},0x{:X},{},0x{:X},{},{},{}\n", c.tick, c.root_sprite, c.feat, c.item, (uint)c.cb, c.time, c.subs, c.result);
134 total_microseconds += c.time;
135 }
136 }
137
138 this->Abort();
139 return total_microseconds;
140}
141
142void NewGRFProfiler::Abort()
143{

Callers 4

CheckMD5Method · 0.45
FinishAllMethod · 0.45
CalcGRFMD5SumFunction · 0.45
AddFileMethod · 0.45

Calls 8

AbortMethod · 0.95
GetOutputFilenameMethod · 0.95
byteswapFunction · 0.85
FioFOpenFileFunction · 0.85
IConsolePrintFunction · 0.70
printFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected