Skip to content
This repository has been archived by the owner on Jul 14, 2018. It is now read-only.

Commit

Permalink
changed the location of when we time the regex matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manoj Dayaram committed May 29, 2012
1 parent b9db2eb commit 581ceb9
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions bstorm/reg.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Matcher interface {
type Task struct {
str string
m Matcher
t time.Time
}

var TaskChann chan *Task
Expand All @@ -51,11 +52,13 @@ func render_pages(name string, marray []Matcher, num_routines, num_renders int)
go func () {
runtime.LockOSThread()
for j := 0; j < num_renders; j++ {
t := time.Now()
var totalDuration int64 = 0
for i := 0; i < NNN; i++ {
m.MatchString(STR)
}
println(name + "-average: ", time.Since(t).Nanoseconds()/int64(1000*NNN), "us")
t := time.Now()
m.MatchString(STR)
totalDuration += time.Since(t).Nanoseconds()
}
println(name + "-average: ", totalDuration/int64(1000*NNN), "us")
}
}()
}
Expand All @@ -64,7 +67,7 @@ func render_pages(name string, marray []Matcher, num_routines, num_renders int)
func render_pages2(name string, marray []Matcher, num_routines, num_renders int) {
go func() {
for i := 0; i < 100000; i ++ {
t := &Task{str: STR, m: marray[0]}
t := &Task{str: STR, m: marray[0], t: time.Now()}
TaskChann <- t
}
}()
Expand All @@ -73,12 +76,13 @@ func render_pages2(name string, marray []Matcher, num_routines, num_renders int)
go func () {
runtime.LockOSThread()
for j := 0; j < num_renders; j++ {
t := time.Now()
var totalDuration int64 = 0
for i := 0; i < NNN; i++ {
task := <- TaskChann
m.MatchString(task.str)
}
println(name + "-average: ", time.Since(t).Nanoseconds()/int64(1000*NNN), "us")
task := <-TaskChann
m.MatchString(task.str)
totalDuration += time.Since(task.t).Nanoseconds()
}
println(name + "-average: ", totalDuration/int64(1000*NNN), "us")
}
}()
}
Expand Down

0 comments on commit 581ceb9

Please sign in to comment.