| |||||||||||||
Profiling and code coverage via the Remote Invocation Protocol Description
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
mprf.mos (!******************************************************* * Mosel Example Programs * * ====================== * * * * file mprf.mos * * ````````````` * * Example for the use of the Mosel language * * (use of the Remote Invocation Ptotocol) * * * * Implements a profiler written in Mosel * * * * (c) 2015 Fair Isaac Corporation * * author: Y. Colombani, 2015 * *******************************************************!) model mprf uses 'mmjobs','mmsystem' parameters SRC="qsort.mos" end-parameters forward procedure showprof(path:string) declarations MO:Mosel M:Model end-declarations if connect(MO,"")<0 then exit(1) end-if if compile("G",SRC,"tmp:bimfile")<>0 then writeln("Compilation failed") exit(1) end-if nid:=getid(MO) load(MO,M,"rmt:[-1]tmp:bimfile") ! switch model to profile mode setcontrol(M,"runmode","2") run(M) waitfor(EVENT_END,-1,WAIT_EXACT) dropnextevent showprof("") !fcopy("rmt:["+nid+"]mcmd:profres-t@1","") !******************************* !* Decode profile information !******************************* procedure showprof(path:string) declarations tottime:real ! total time nbsub:integer ! nb of submodels profiled nbnoprf:integer ! nb of submodels not profiled lines:array(Rlines:range) of integer ! line numbers (in file) iters:array(Rlines) of integer ! nb of iterations times:array(Rlines) of real ! time spent on line elaps:array(Rlines) of real ! last time the line was executed files:array(Rfiles:range) of string ! file names starts:array(Rstarts:range) of integer ! line ref where the file starts spc,tl:text msg:list of text end-declarations ! Request 'profres' (profiler result) ! mcmd:profres@M[ path] ! M: master model (it must have been run with the profiler) ! path: a submodel e.g. 1.3 is the 3d submodel of the 1st submodel ! option -z: compress with gzip initialisations from "bin:zlib.gzip:rmt:["+nid+"]mcmd:profres-z@1 "+path tottime nbsub nbnoprf Rlines lines iters times elaps Rfiles files Rstarts starts end-initialisations f:=-1 cl:=0 spc:=" "*14 forall(l in Rlines) do if l=starts(f+1) then if f>=0 then fclose(F_INPUT); end-if f+=1 writeln writeln("*"*30," File:",files(f), if(path.size>0," submodel:"+path," master model")," ","*"*30) writeln fopen(files(f),F_INPUT) cl:=0 end-if dum:=readtextline(tl) cl+=1 while(cl<lines(l)) do write(spc,tl) dum:=readtextline(tl) cl+=1 end-do write(textfmt(iters(l),4)," ",textfmt(times(l),5,2)," ",tl) end-do fclose(F_INPUT) ! Let's process all the submodels if path.size>0 then path:=path+"."; end-if forall(i in 1..nbsub) showprof(path+i) write("\nRetrieving result:") ! options -tp: text file and result expressed as percentage initialisations from "rmt:["+nid+"]mcmd:profrep-tp@1 "+path msg end-initialisations forall(m in msg) write(m) end-procedure end-model | |||||||||||||
© Copyright 2024 Fair Isaac Corporation. |