Go to the documentation of this file.00001
00002
00003 #include "osl/progress/effect5x3.h"
00004 #include "osl/progress/effect5x3d.h"
00005 #include "osl/record/csaString.h"
00006 #include "osl/record/csaRecord.h"
00007 #include "osl/misc/perfmon.h"
00008
00009 #include <iostream>
00010 #include <fstream>
00011
00012 using namespace osl;
00013
00014 void usage(const char *program_name)
00015 {
00016 std::cerr << program_name << " csafiles\n";
00017 exit(1);
00018 }
00019
00020 size_t skip_first = 0;
00021 void run(const char *filename);
00022 void finish();
00023
00024 int main(int argc, char **argv)
00025 {
00026 const char *program_name = argv[0];
00027 bool error_flag = false;
00028
00029 extern char *optarg;
00030 extern int optind;
00031 char c;
00032 while ((c = getopt(argc, argv, "s:vh")) != EOF)
00033 {
00034 switch(c)
00035 {
00036 case 's': skip_first = atoi(optarg);
00037 break;
00038 default: error_flag = true;
00039 }
00040 }
00041 argc -= optind;
00042 argv += optind;
00043
00044 if (error_flag || (argc < 1))
00045 usage(program_name);
00046
00047 try
00048 {
00049 for (int i=0; i<argc; ++i)
00050 {
00051 run(argv[i]);
00052 }
00053 finish();
00054 }
00055 catch (std::exception& e)
00056 {
00057 std::cerr << e.what() << "\n";
00058 return 1;
00059 }
00060 catch (...)
00061 {
00062 throw;
00063 }
00064 }
00065
00066 unsigned long long total_cycles=0;
00067 unsigned long long total_cycles_naive=0;
00068 unsigned long long positions = 0;
00069 void run(const char *filename)
00070 {
00071 Record rec=CsaFile(filename).getRecord();
00072 NumEffectState state(rec.getInitialState());
00073 const vector<osl::Move> moves=rec.getMoves();
00074
00075 size_t i=0;
00076 progress::Effect5x3 progress(state);
00077 while (true)
00078 {
00079 if (i >= moves.size())
00080 break;
00081 const Move move = moves[i++];
00082 state.makeMove(move);
00083 if (i >= skip_first) {
00084 misc::PerfMon clock;
00085 progress.update(state, move);
00086 total_cycles += clock.stop();
00087 ++positions;
00088 }
00089 }
00090 }
00091
00092 void finish()
00093 {
00094 std::cerr << "p " << total_cycles << " / " << positions << " = "
00095 << total_cycles/(double)positions << "\n";
00096 }
00097
00098
00099
00100
00101
00102