/* tmc.inc * * the tmc ("total macro calls") file provides macros for reporting the * number of times specified macros have been called. * * Persistence of Vision Raytracer version 3.8 or later. * * macro tmcAdd(dict,key) * * a call to this macro needs to be added to every macro of interest. * 'key' can be the macro's actual name, or some other identifying string * (without space or control characters). * 'dict' is a dictionary variable created by 'tmcNew()'. * the macro expands to ("returns") nothing. * * macro tmcNew() * * creates and returns a dictionary to use. * * macro tmcReport(dict) * * calling this macro '#debug' outputs a list of the number of calls * made to each macro instrumented with the above, one per line, followed * by a line of "grand-totals". the macro returns nothing. * * version: 202205.2 */ #ifndef (tmc__include_temp) #declare tmc__include_temp = version; #version 3.8; #ifdef (View_POV_Include_Stack) #debug "including 'tmc.inc'\n" #end /* ------------------------------------------------------------------------- */ #macro tmc__incr(v_,optional n_) #if (!defined(local.n_)) #local n_ = 1; #end #local v_ = v_ + n_; #end #macro tmc__hyphen(n_) #local s_ = ""; #for (i_,1,n_) #local s_ = concat(s_,"-"); #end s_ #end #macro tmc__emitLine(n_,s_) #debug concat(" ",str(n_,10,0)," : ",s_,"\n") #end #macro tmc__gttl(d_) #local t_ = 0; #for (i_,0,dimension_size(d_.k_,1)-1) tmc__incr(t_,d_[d_.k_[i_]]) #end t_ #end /* ------------------------------------------------------------------------- */ #macro tmcAdd(dict_,key_) #if (!defined(dict_.tmcid_)) #error "tmcAdd: bad dictionary argument." #end #if (defined(dict_[key_])) tmc__incr(dict_[key_],) #else #local dict_.k_[dimension_size(dict_.k_,1)] = key_; #local dict_[key_] = 1; #end #end #macro tmcNew() dictionary {.tmcid_: true, .k_: array} #end #macro tmcReport(dict_) #if (!defined(dict_.tmcid_)) #error "tmcReport: bad dictionary argument." #end #debug concat(tmc__hyphen(5),"[tmc]",tmc__hyphen(62),"\n") #for (i_,0,dimension_size(dict_.k_,1)-1) tmc__emitLine(dict_[dict_.k_[i_]],dict_.k_[i_]) #end #debug concat(" ",tmc__hyphen(10)," : ",tmc__hyphen(10),"\n") tmc__emitLine(tmc__gttl(dict_),str(dimension_size(dict_.k_,1),0,0)) #debug concat(tmc__hyphen(72),"\n") #end #version tmc__include_temp; #end /* -------------------------------------------------------------------- * * the content above is covered by the GNU General Public License v3+ * * copyright (c) 2022 jr . * * all rights reserved. * * -------------------------------------------------------------------- */