Skip to content

Commit

Permalink
adds the del() log to world.log at roundend and allows the runtime co…
Browse files Browse the repository at this point in the history
…ndenser to parse and condense it
  • Loading branch information
duncathan committed Oct 6, 2015
1 parent 52e072c commit e2ed83b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
8 changes: 8 additions & 0 deletions code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ var/datum/subsystem/ticker/ticker
for(var/i in total_antagonists)
log_game("[i]s[total_antagonists[i]].")

//Adds the del() log to world.log in a format condensable by the runtime condenser found in tools
if(SSgarbage.didntgc.len)
var/dellog = ""
for(var/path in SSgarbage.didntgc)
dellog += "Path : [path] \n"
dellog += "Failures : [SSgarbage.didntgc[path]] \n"
world.log << dellog

return 1

/datum/subsystem/ticker/proc/send_random_tip()
Expand Down
72 changes: 69 additions & 3 deletions tools/Runtime Condenser/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

//Make all of these global. It's bad yes, but it's a small program so it really doesn't affect anything.
Expand All @@ -28,15 +30,20 @@ using namespace std;
string storedSource[maxStorage+1];
string storedUsr[maxStorage+1];
string storedSrc[maxStorage+1];

string storedHardDel[maxStorage+1];

//Stat tracking stuff for output
unsigned int totalRuntimes = 0;
unsigned int totalUniqueRuntimes = 0;
unsigned int totalInfiniteLoops = 0;
unsigned int totalUniqueInfiniteLoops = 0;
unsigned int totalHardDels = 0;
unsigned int totalUniqueHardDels = 0;

//Misc
unsigned int numRuntime[maxStorage+1]; //Number of times a specific runtime has occured
unsigned int numHardDel[maxStorage+1]; //Number of times a specific hard del has occured
bool checkNextLines = false; //Used in case byond has condensed a large number of similar runtimes
int storedIterator = 0; //Used to remember where we stored the runtime

Expand Down Expand Up @@ -94,7 +101,7 @@ bool readFromFile()
break;
}

//We've never encoutnered this
//We've never encountered this
if(storedRuntime[i] == "Blank")
{
storedRuntime[i] = currentLine;
Expand Down Expand Up @@ -122,7 +129,7 @@ bool readFromFile()
break;
}

//We've never encoutnered this
//We've never encountered this
if(storedRuntime[i] == "Blank")
{
storedRuntime[i] = currentLine;
Expand All @@ -135,6 +142,41 @@ bool readFromFile()
}
}
}

//Found a hard del!
else if(currentLine.find("Path :") != std::string::npos)
{
//this is pretty ugly but the alternative was implementing regex which I haven't the slightest idea how to do
//it takes advantage of the formatting of the line to extract the amount of failures
std::string tmp;
char c;
int failures;
std::stringstream ss(nextLine);
ss >> tmp >> c >> failures;

totalHardDels += failures;

for(int i=0; i <= maxStorage; i++)
{

//We've already encountered this
if(currentLine == storedHardDel[i])
{
numHardDel[i] += failures;
break;
}

//We've never encountered this
if(storedHardDel[i] == "Blank")
{
storedHardDel[i] = currentLine;
numHardDel[i] = failures;
checkNextLines = true;
totalUniqueHardDels++;
break;
}
}
}
}
}
else
Expand All @@ -158,16 +200,28 @@ bool writeToFile()
}
if(totalInfiniteLoops > 0)
{
outputFile << "Total infinite loops: " << totalInfiniteLoops << endl;
outputFile << "Total infinite loops: " << totalInfiniteLoops << endl << endl;
}
outputFile << "Total unique runtimes: " << totalUniqueRuntimes << endl;
outputFile << "Total runtimes: " << totalRuntimes << endl << endl;
if(totalUniqueHardDels > 0)
{
outputFile << "Total unique hard deletions: " << totalUniqueHardDels << endl;
}
if(totalHardDels > 0)
{
outputFile << "Total hard deletions: " << totalHardDels << endl << endl;
}

//Display a warning if we've hit the maximum space we've allocated for storage
if(totalUniqueRuntimes + totalUniqueInfiniteLoops >= maxStorage)
{
outputFile << "Warning: The maximum number of unique runtimes has been hit. If there were more, they have been cropped out.\n\n";
}
if(totalUniqueHardDels >= maxStorage)
{
outputFile << "Warning: The maximum number of unique hard deletions has been hit. If there were more, they have been croped out.\n\n";
}


//If we have infinite loops, display them first.
Expand Down Expand Up @@ -203,6 +257,16 @@ bool writeToFile()
if(storedUsr[i] != "Blank") outputFile << storedUsr[i] << endl;
if(storedSrc[i] != "Blank") outputFile << storedSrc[i] << endl;
}

if(totalHardDels > 0)
{
outputFile << "** Hard deletions **";
for(int i=0; i <= maxStorage; i++)
{
if(numHardDel[i] != 0) outputFile << endl << endl << "The following path has failed to GC " << numHardDel[i] << " time(s).\n";
if(storedHardDel[i] != "Blank") outputFile << storedRuntime[i] << endl;
}
}
outputFile.close();
}
else
Expand Down Expand Up @@ -278,6 +342,8 @@ int main() {
storedUsr[i] = "Blank";
storedSrc[i] = "Blank";
numRuntime[i] = 0;
storedHardDel[i] = "Blank";
numHardDel[i] = 0;

}

Expand Down
Binary file modified tools/Runtime Condenser/RuntimeCondenser.exe
Binary file not shown.

0 comments on commit e2ed83b

Please sign in to comment.