24 for(
int i=1; i <= scnt; ++i) {
29 std::map<int, Idx> map_evidx;
30 for(
int i=0; i < evcnt; ++i) {
38 for(
int i = 0; i < tc; ++i) {
52 std::cout <<
"perfloop: " << message << std::endl;
53 std::cout <<
"" << std::endl;
56 std::cout <<
"perfloop: version " <<
VersionString() << std::endl;
57 std::cout <<
"" << std::endl;
58 std::cout <<
"perfloop: usage: " << std::endl;
59 std::cout <<
" perfloop [-q][-cs <nnn>][-ce <nnn>][-ct <nn>] [-n <nn>] " << std::endl;
60 std::cout <<
"where " << std::endl;
61 std::cout <<
" -q: less console output " << std::endl;
62 std::cout <<
" -cs <nnn>: number of states <nnn> " << std::endl;
63 std::cout <<
" -ce <nnn>: number of events <nnn> " << std::endl;
64 std::cout <<
" -ct <nnn>: number of transitions <nnn> per state" << std::endl;
65 std::cout <<
" -n <nnn>: repetition of test" << std::endl;
66 std::cout <<
" -s: use zero seed for random number generator" << std::endl;
67 std::cout <<
"" << std::endl;
68 std::cout <<
"" << std::endl;
74 int main(
int argc,
char* argv[]){
85 for(
int i=1; i<argc; i++) {
86 std::string option(argv[i]);
88 if((option==
"-q") || (option==
"--quiet")) {
93 if((option==
"-cs") || (option==
"--states")) {
95 param_cs=
ToIdx(argv[i]);
96 if(param_cs <=0)
usage_exit(
"positive state count required");
100 if((option==
"-ce") || (option==
"--events")) {
102 param_ce=
ToIdx(argv[i]);
103 if(param_ce <=0)
usage_exit(
"positive event count required");
107 if((option==
"-ct") || (option==
"--transition-density")) {
109 param_ct=
ToIdx(argv[i]);
110 if(param_ct <=0)
usage_exit(
"positive transition count required");
114 if((option==
"-n") || (option==
"--loop-count")) {
116 param_n=
ToIdx(argv[i]);
117 if(param_ce <=0)
usage_exit(
"positive loop count");
121 if((option==
"-s") || (option==
"--seed0")) {
126 if((option==
"-?") || (option==
"--help")) {
131 if(option.c_str()[0]==
'-') {
143 faudes_systime_t now;
144 faudes_gettimeofday(&now);
151 faudes_systime_t lastprint;
152 faudes_gettimeofday(&lastprint);
155 faudes_mstime_t overall_duration = 0;
158 long int overall_reduction = 0;
161 for(
int i=0; i<param_n; ++i) {
168 faudes_systime_t start;
169 faudes_gettimeofday(&start);
172 std::map<faudes::Idx, faudes::Idx> pmap;
174 calcBisimulation(grand,pmap, gbisim);
177 faudes_systime_t stop;
178 faudes_gettimeofday(&stop);
179 faudes_mstime_t delta;
181 overall_duration += delta;
184 long int reduction = grand.
Size()-gbisim.
Size();
185 overall_reduction += reduction;
189 faudes_mstime_t deltaprint;
191 if((deltaprint>2000) && param_q==0) {
192 std::cout <<
"perfloop: state set reduction #" << reduction <<
" amounts to " <<
193 ((
long int)(10.0 * 100.0 * reduction/grand.
Size())) / 10.0 <<
"%" << std::endl;
194 std::cout <<
"perfloop: time elapse " << ((delta + 50) / 100) / 10.0 <<
"sec." << std::endl;
202 std::cout <<
"perfloop: average state set reduction " <<
203 ((
long int)(10.0 * 100.0 * overall_reduction / param_cs / param_n)) / 10.0 <<
"%" << std::endl;
204 long int average_duration = ((double) overall_duration) / (param_n*100.0) + 0.5;
205 std::cout <<
"perfloop: average duration per loop " << ((double) average_duration) / 10.0 <<
"sec." << std::endl;
StateSet::Iterator StatesBegin(void) const
bool SetTransition(Idx x1, Idx ev, Idx x2)
void SetInitState(Idx index)
StateSet::Iterator StatesEnd(void) const
long ran_uniform_int(long a, long b)
std::string VersionString()
Idx ToIdx(const std::string &rString)
std::string ToStringInteger(Int number)
int main(int argc, char *argv[])
void RandomGenerator(int scnt, int evcnt, int tcnt, Generator &rRes)
void usage_exit(const std::string &message="")