📄 time.cc
字号:
// time.h // W.Langdon@cs.ucl.ac.uk $Revision: 1.8 $ 20 April 1995//Modifications (reverse order)://WBL 15 Oct 95 Add code for branching//WBL 20 Apr 95 #include <assert.h>#include "pch.h"#include "chrome.h"#include "time.h"//#include "Primitives.h"#include "gp.h"extern evalnode* fast_tree_starts [NUM_TREES]; // start of each tree run_time::run_time(): //SetupEval MUST BE CALLED FIRST time_(0), num_times(0), ip(NULL){memset(tree_base_times,0,sizeof(tree_base_times));for(int t=0; t<NUM_TREES; t++) { ip = fast_tree_starts[t]; int start_index = num_times - 1; tree_base_times[t] = subtree(); sort(start_index);//end_index = mum_times - 1;};}//end run_time#undef PARGNUM#define PARGNUM(ip) (ThisProblem->funclist[ip->op]->argnum)int run_time::subtree(){ timetyp rval = 0; int args=1; while (args > 0) { const int num_args = PARGNUM(ip); rval++;// int calling; int num_conditional_args; if(IsLoop(ip->op)) { ip++; for(int a=1; a<num_args; a++) { rval += subtree(); }//arguments to loop evalnode* old_ip = ip; --old_ip; //dec since Eval inc before exceution add(old_ip,subtree()); args--; } else if((num_conditional_args=IsBranch(ip->op))>0) { ip++; for(int a=0; a<(num_args-num_conditional_args); a++) { rval += subtree(); }//arguments to if for(; a<num_args; a++) { evalnode* old_ip = ip; --old_ip; //dec since Eval incs add(old_ip,subtree()); } args--; } else { ip++; args += num_args -1; } };//end which function return rval;}//end subtreevoid run_time::sort(const int lower){//keep times in order of ip so can do fast search using binary chopfor(int i = lower; i < num_times; i++)for(int j = i + 1; j < num_times; j++) if(times[i].ip>times[j].ip) { subtree_time temp = times[j]; times[j] = times[i]; times[i] = temp; };}//end run_time::sort()ostream& operator<<(ostream& os,run_time& rt){os<<"time_ "<<rt.time_<<endl;for(int i=0;i<NUM_TREES;i++) { os<<rt.tree_base_times[i]<<" ";}os<<endl;for(i=0;i<rt.num_times;i++) { os<<i<<" "<<rt.times[i].ip<<",\t"<<rt.times[i].ttime<<endl;}return os;}//end <<
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -