summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-12-01 11:10:52 -0500
committerAdrian Thurston <thurston@complang.org>2014-12-01 11:10:52 -0500
commit0d113943c37e1d361986cdcc6abbce5159afe94c (patch)
tree2919e86b1ac4803843b3a8ef03a32987184b0f4f
parent50c627b0afcd091c6147f37c535cb9e8efc04cdb (diff)
downloadragel-0d113943c37e1d361986cdcc6abbce5159afe94c.tar.gz
added table data to the statistics printing
Gives a summary of count and size for each table, and total of the size at the end. refs #21
-rw-r--r--ragel/cdcodegen.cpp20
-rw-r--r--ragel/cdcodegen.h5
-rw-r--r--ragel/gendata.cpp15
-rw-r--r--ragel/gendata.h2
-rw-r--r--ragel/parsedata.cpp12
5 files changed, 37 insertions, 17 deletions
diff --git a/ragel/cdcodegen.cpp b/ragel/cdcodegen.cpp
index 251ff3b5..bc19ab88 100644
--- a/ragel/cdcodegen.cpp
+++ b/ragel/cdcodegen.cpp
@@ -29,7 +29,6 @@
#include <string>
#include <assert.h>
-
using std::ostream;
using std::ostringstream;
using std::string;
@@ -77,7 +76,8 @@ TableArray::TableArray( FsmCodeGen &codeGen, HostType *hostType, std::string nam
iall(stringTables ? IALL_STRING : IALL_INTEGRAL ),
first(true),
ln(0),
- str(stringTables)
+ str(stringTables),
+ count(0)
{}
void TableArray::OPEN()
@@ -103,6 +103,19 @@ void TableArray::CLOSE()
codeGen.CLOSE_ARRAY();
out << "\n";
}
+
+ if ( printStatistics ) {
+ cout << name << "\t" << count << "\t" <<
+ ( count * hostType->size ) << "\t" << hostType->TYPE() << endl;
+ }
+
+ codeGen.tableData += count * hostType->size ;
+}
+
+void FsmCodeGen::statsSummary()
+{
+ if ( printStatistics )
+ cout << "table-data\t" << tableData << endl << endl;
}
void FsmCodeGen::genLineDirective( ostream &out )
@@ -115,7 +128,8 @@ void FsmCodeGen::genLineDirective( ostream &out )
/* Init code gen with in parameters. */
FsmCodeGen::FsmCodeGen( ostream &out )
:
- CodeGenData( out )
+ CodeGenData( out ),
+ tableData( 0 )
{
}
diff --git a/ragel/cdcodegen.h b/ragel/cdcodegen.h
index 96e1d7e9..0713d07f 100644
--- a/ragel/cdcodegen.h
+++ b/ragel/cdcodegen.h
@@ -81,6 +81,7 @@ struct TableArray
}
ln += 1;
first = false;
+ count += 1;
}
void SVAL( long long value )
@@ -160,6 +161,7 @@ struct TableArray
bool first;
long ln;
bool str;
+ long long count;
};
/*
@@ -177,6 +179,8 @@ public:
virtual void writeFirstFinal();
virtual void writeError();
+ virtual void statsSummary();
+
protected:
friend TableArray;
@@ -291,6 +295,7 @@ protected:
bool testEofUsed;
bool againLabelUsed;
bool useIndicies;
+ long long tableData;
void genLineDirective( ostream &out );
diff --git a/ragel/gendata.cpp b/ragel/gendata.cpp
index 65f0b52f..fbb4b1df 100644
--- a/ragel/gendata.cpp
+++ b/ragel/gendata.cpp
@@ -1062,6 +1062,12 @@ void CodeGenData::write_option_error( InputLoc &loc, char *arg )
source_warning(loc) << "unrecognized write option \"" << arg << "\"" << endl;
}
+void CodeGenData::statsSummary()
+{
+ if ( printStatistics )
+ cout << endl;
+}
+
/* returns true if the following section should generate line directives. */
bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
{
@@ -1082,7 +1088,14 @@ bool CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
else
write_option_error( loc, args[i] );
}
+
+ if ( printStatistics ) {
+ cout << "fsm-name\t" << fsmName << endl;
+ cout << "fsm-states\t" << redFsm->stateList.length() << endl;
+ }
+
writeData();
+ statsSummary();
}
else if ( strcmp( args[0], "init" ) == 0 ) {
out << '\n';
@@ -1155,5 +1168,3 @@ ostream &CodeGenData::source_error( const InputLoc &loc )
cerr << sourceFileName << ":" << loc.line << ":" << loc.col << ": ";
return cerr;
}
-
-
diff --git a/ragel/gendata.h b/ragel/gendata.h
index 071c6017..c92a1682 100644
--- a/ragel/gendata.h
+++ b/ragel/gendata.h
@@ -72,6 +72,8 @@ struct CodeGenData
virtual void writeFirstFinal() {};
virtual void writeError() {};
+ virtual void statsSummary();
+
/* This can also be overwridden to modify the processing of write
* statements. */
virtual bool writeStatement( InputLoc &loc, int nargs, char **args );
diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp
index 8ce89db6..22f51c01 100644
--- a/ragel/parsedata.cpp
+++ b/ragel/parsedata.cpp
@@ -1439,12 +1439,6 @@ void ParseData::generateReduced( InputData &inputData )
/* Write out with it. */
backendGen.makeBackend();
-
- if ( printStatistics ) {
- cerr << "fsm name : " << sectionName << endl;
- cerr << "num states: " << sectionGraph->stateList.length() << endl;
- cerr << endl;
- }
}
void ParseData::generateXML( ostream &out )
@@ -1456,11 +1450,5 @@ void ParseData::generateXML( ostream &out )
/* Write out with it. */
codeGen.writeXML();
-
- if ( printStatistics ) {
- cerr << "fsm name : " << sectionName << endl;
- cerr << "num states: " << sectionGraph->stateList.length() << endl;
- cerr << endl;
- }
}