Skip to content

Commit

Permalink
Improve profiling system.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Aug 26, 2017
1 parent a843804 commit 3b35ea5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/test_rubi.m
Expand Up @@ -12,10 +12,10 @@
If[res === testp[[4]], Print[thei]];
);

(*While[testi <= Length[testproblems],
While[testi <= Length[testproblems],
(*Print["hi ", testi]*)
If[(testi>34&&testi<47)||MemberQ[{50, 52, 53, 54, 55, 56, 57, 58, 59, 211, 214, 215, 216, 218, 222, 223, 224, 225, 228, 229, 231, 232, 233}, testi] || (testi>=160&&testi<=166), Null,
runRubiTest[testi];
];
testi = testi+1;
];*)
];
5 changes: 3 additions & 2 deletions expreduce/builtin_system.go
Expand Up @@ -198,9 +198,10 @@ func GetSystemDefinitions() (defs []Definition) {
sym, ok := this.Parts[1].(*Symbol)
if ok {
if sym.Name == "System`True" {
errorStr := "Invalid level. Must be one of {Debug, Info, Notice}."
levelSym, lsOk := this.Parts[2].(*Symbol)
if !lsOk {
return NewExpression([]Ex{&Symbol{"System`Error"}, &String{"Invalid level."}})
return NewExpression([]Ex{&Symbol{"System`Error"}, &String{errorStr}})
}
if levelSym.Name == "System`Debug" {
es.DebugOn(logging.DEBUG)
Expand All @@ -209,7 +210,7 @@ func GetSystemDefinitions() (defs []Definition) {
} else if levelSym.Name == "System`Notice" {
es.DebugOn(logging.NOTICE)
} else {
return NewExpression([]Ex{&Symbol{"System`Error"}, &String{"Invalid level."}})
return NewExpression([]Ex{&Symbol{"System`Error"}, &String{errorStr}})
}
return &Symbol{"System`Null"}
} else if sym.Name == "System`False" {
Expand Down
2 changes: 2 additions & 0 deletions expreduce/caslogger.go
Expand Up @@ -40,11 +40,13 @@ func (this *CASLogger) Errorf(fmt string, args ...interface{}) {
func (this *CASLogger) DebugOn(level logging.Level) {
this.leveled.SetLevel(level, "")
this.debugState = true
this.SetProfiling(true)
}

func (this *CASLogger) DebugOff() {
this.leveled.SetLevel(logging.ERROR, "")
this.debugState = false
this.SetProfiling(false)
}

func (this *CASLogger) DebugState() bool {
Expand Down
7 changes: 6 additions & 1 deletion expreduce/time_counter.go
Expand Up @@ -7,17 +7,21 @@ import (
)

type TimeMap map[string]float64
type CountMap map[string]int64

type TimeCounter struct {
times TimeMap
counts CountMap
}

func (tc *TimeCounter) Init() {
tc.times = make(TimeMap)
tc.counts = make(CountMap)
}

func (tc *TimeCounter) AddTime(key string, elapsed float64) {
tc.times[key] += elapsed
tc.counts[key] += 1
}

func (tc *TimeCounter) Update(other *TimeCounter) {
Expand All @@ -43,7 +47,8 @@ func (tc *TimeCounter) TruncatedString(numToPrint int) string {
break
}
for _, s := range n[k] {
buffer.WriteString(fmt.Sprintf("%v, %v\n", k, s))
count := tc.counts[s]
buffer.WriteString(fmt.Sprintf("%v, %v, %v\n", k, count, s))
numPrinted++
}
}
Expand Down

0 comments on commit 3b35ea5

Please sign in to comment.