diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-07-03 15:04:26 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-07-03 15:04:26 (GMT) |
commit | 19d4e8ae2e472dd364ffeff1e096d3f75d5251c4 (patch) | |
tree | f006846b1f4bf207d0c8229b52d4948bb1497b63 /contrib/benchmarks/scxmlcc | |
parent | fbda090a39ad02c937345bee204ca3f77106b2bf (diff) | |
download | uscxml-19d4e8ae2e472dd364ffeff1e096d3f75d5251c4.zip uscxml-19d4e8ae2e472dd364ffeff1e096d3f75d5251c4.tar.gz uscxml-19d4e8ae2e472dd364ffeff1e096d3f75d5251c4.tar.bz2 |
BEnchmarks and performance improvements
Diffstat (limited to 'contrib/benchmarks/scxmlcc')
-rw-r--r-- | contrib/benchmarks/scxmlcc/makefile | 35 | ||||
-rw-r--r-- | contrib/benchmarks/scxmlcc/statesPerSecond.cpp | 47 |
2 files changed, 82 insertions, 0 deletions
diff --git a/contrib/benchmarks/scxmlcc/makefile b/contrib/benchmarks/scxmlcc/makefile new file mode 100644 index 0000000..0466459 --- /dev/null +++ b/contrib/benchmarks/scxmlcc/makefile @@ -0,0 +1,35 @@ +#************************************************************************* +#** Copyright (C) 2013 Jan Pedersen <jp@jp-embedded.com> +#** +#** This program is free software: you can redistribute it and/or modify +#** it under the terms of the GNU General Public License as published by +#** the Free Software Foundation, either version 3 of the License, or +#** (at your option) any later version. +#** +#** This program is distributed in the hope that it will be useful, +#** but WITHOUT ANY WARRANTY; without even the implied warranty of +#** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#** GNU General Public License for more details. +#** +#** You should have received a copy of the GNU General Public License +#** along with this program. If not, see <http://www.gnu.org/licenses/>. +#************************************************************************* + +OBJS := main.o cpp_output.o scxml_parser.o version.o +CPPFLAGS := -Wall -MD -MP -O2 + +all: scxmlcc + +scxmlcc: $(OBJS) + $(CXX) -o $@ $^ -L/opt/local/lib -lboost_program_options-mt -lboost_system-mt -lboost_filesystem-mt + +clean: + rm -f $(OBJS) $(OBJS:.o=.d) scxmlcc autorevision.mk version_auto.h + +autorevision.mk: + autorevision -tsh > $@ && sh makerevision.sh || truncate -s0 version_auto.h +.PHONY: autorevision.mk +-include autorevision.mk + +-include $(OBJS:.o=.d) + diff --git a/contrib/benchmarks/scxmlcc/statesPerSecond.cpp b/contrib/benchmarks/scxmlcc/statesPerSecond.cpp new file mode 100644 index 0000000..e0dc7b2 --- /dev/null +++ b/contrib/benchmarks/scxmlcc/statesPerSecond.cpp @@ -0,0 +1,47 @@ +#include <iostream> +#include <chrono> +#include <stdlib.h> + +#include "test.h" + +using namespace std; +using namespace std::chrono; + +typedef MACHINE_NAME sc; + +long iterations = 0; +long initMs = 0; +system_clock::time_point report; +system_clock::time_point endTime; + +template<> void sc::state_actions<sc::state_mark>::enter(sc::data_model &m) +{ + iterations++; + system_clock::time_point now = system_clock::now(); + + if (now > report) { + report = now + seconds(1); + std::cout << initMs << ", " << iterations << std::endl; + iterations = 0; + } + if (now > endTime) { + ::exit(EXIT_SUCCESS); + } +} + +int main(int argc, char *argv[]) +{ + system_clock::time_point start = system_clock::now(); + + sc sc0; + system_clock::time_point now = system_clock::now(); + + initMs = duration_cast<milliseconds>(now - start).count(); + + start = now; + report = start + seconds(1); + endTime = start + seconds(10); + + sc0.init(); + return 0; +} |