Commit 302241b4 authored by Marc's avatar Marc
Browse files

Fix compilation when timing, or debugging

parent cdd696df
......@@ -5,6 +5,8 @@ Simulating Turing machines, or finite state automata is easy when they have expl
But if they use transition patterns, it may quickly become awful. %TuringSim is there for you! It is a very configurable
framework with a lot of predefined machine types, that makes running computation models easy and efficient.
Check out the [repo](https://gitlab.marc-chevalier.com/marc/turingsim).
\section An Overview
The fundamental class is TuringSim::Machine::Machine. It is the most abstract class representing a machine.
......
......@@ -53,13 +53,12 @@ namespace TuringSimTest::Machine::Turing {
size_t initSteps = 0;
runner.step(initSteps);
for(size_t i = initSteps; i < nbIter && runner.isRunning(); i += step) {
using Utils::Debug::operator<<;
using Debug::operator<<;
runner.step(step);
cout << listener.getNumberOfTransitions() << " ";
cout << runner.getCurrentState() << " " ;
cout << observer.getPosition() << " ";
cout << observer.getTape()[observer.getPosition()] << " ";
bool first = true;
for(const string& cell: observer.getTape()) {
if(cell.empty()) {
cout << " ";
......@@ -80,11 +79,11 @@ namespace TuringSimTest::Machine::Turing {
auto duration = duration_cast<nanoseconds>(stop - start);
double speed = (static_cast<double>(nbIter)/static_cast<double>(duration.count())) * 1.e9;
double timePerTransition = static_cast<double>(duration.count())/static_cast<double>(nbIter);
using Utils::Debug::operator<<;
cout << endl << spaceNumber(duration.count()) << " ns" << endl;
cout << spaceNumber(nbIter) << " transitions" << endl;
cout << spaceNumber(static_cast<int>(speed)) << " transitions/s" << endl;
cout << spaceNumber(static_cast<int>(timePerTransition)) << " ns/transition" << endl << endl;
using Debug::operator<<;
cout << endl << Debug::spaceNumber(duration.count()) << " ns" << endl;
cout << Debug::spaceNumber(nbIter) << " transitions" << endl;
cout << Debug::spaceNumber(static_cast<int>(speed)) << " transitions/s" << endl;
cout << Debug::spaceNumber(static_cast<int>(timePerTransition)) << " ns/transition" << endl << endl;
#endif
#endif
......
......@@ -186,11 +186,11 @@ namespace TuringSimTest::Runner {
auto duration = duration_cast<nanoseconds>(stop - start);
double speed = static_cast<double>(listener.getNumberOfTransitions()) * 1.e9 / static_cast<double>(duration.count());
double timePerTransition = static_cast<double>(duration.count())/static_cast<double>(listener.getNumberOfTransitions());
using Utils::Debug::operator<<;
cout << endl << spaceNumber(duration.count()) << " ns" << endl;
cout << spaceNumber(listener.getNumberOfTransitions()) << " transitions" << endl;
cout << spaceNumber(static_cast<int>(speed)) << " transitions/s" << endl;
cout << spaceNumber(static_cast<int>(timePerTransition)) << " ns/transition" << endl << endl;
using Debug::operator<<;
cout << endl << Debug::spaceNumber(duration.count()) << " ns" << endl;
cout << Debug::spaceNumber(listener.getNumberOfTransitions()) << " transitions" << endl;
cout << Debug::spaceNumber(static_cast<int>(speed)) << " transitions/s" << endl;
cout << Debug::spaceNumber(static_cast<int>(timePerTransition)) << " ns/transition" << endl << endl;
#endif
CPPUNIT_ASSERT_EQUAL("y"s, runner.getCurrentState());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment