watch: add numstmts

This commit is contained in:
lyyyuna 2021-08-08 16:16:10 +08:00
parent 0704a4ce67
commit 8b1f28225e
2 changed files with 13 additions and 10 deletions

View File

@ -80,8 +80,8 @@ func init() {
cov := fmt.Sprintf("%s:%d.%d,%d.%d %d %d", block.name, cov := fmt.Sprintf("%s:%d.%d,%d.%d %d %d", block.name,
block.pos[3*i+0], uint16(block.pos[3*i+2]), block.pos[3*i+0], uint16(block.pos[3*i+2]),
block.pos[3*i+1], uint16(block.pos[3*i+2] >> 16), block.pos[3*i+1], uint16(block.pos[3*i+2] >> 16),
1, block.stmts,
0) 1)
err = ws.WriteMessage(websocket.TextMessage, []byte(cov)) err = ws.WriteMessage(websocket.TextMessage, []byte(cov))
if err != nil { if err != nil {
@ -131,10 +131,11 @@ type blockInfo struct {
name string name string
pos []uint32 pos []uint32
i int i int
stmts int
} }
// UploadCoverChangeEvent_{{.Random}} is non-blocking // UploadCoverChangeEvent_{{.Random}} is non-blocking
func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) { func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int, stmts uint16) {
if watchEnabled == false { if watchEnabled == false {
return return
@ -146,6 +147,7 @@ func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) {
name: name, name: name,
pos: pos, pos: pos,
i: i, i: i,
stmts: int(stmts),
}: }:
default: default:
} }

View File

@ -419,7 +419,8 @@ func atomicCounterStmt(f *File, counter string) string {
// watchCounterStmt returns the expression: __count[23]++;UploadCoverChangeEvent(blockname, pos[:], index) // watchCounterStmt returns the expression: __count[23]++;UploadCoverChangeEvent(blockname, pos[:], index)
func watchCounterStmt(f *File, counter string) string { func watchCounterStmt(f *File, counter string) string {
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v)", counter, f.random, f.varVar, f.varVar, len(f.blocks)) index := len(f.blocks)
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v, %s.NumStmt[%v])", counter, f.random, f.varVar, f.varVar, index, f.varVar, index)
} }
// QINIU // QINIU