MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / printEndofTestStatsFile

Function printEndofTestStatsFile

tools/cache_perf_tool/main.go:293–328  ·  view source on GitHub ↗
(ctx context.Context, dbContext *db.DatabaseContext)

Source from the content-addressed store, hash-verified

291}
292
293func printEndofTestStatsFile(ctx context.Context, dbContext *db.DatabaseContext) {
294 // Print the csv file to stdout
295 dbContext.UpdateCalculatedStats(ctx)
296 dbStats := dbContext.DbStats
297 // calculate here avg time to cache seq in ms
298 count := dbStats.Database().DCPCachingCount.Value()
299 timeNano := dbStats.Database().DCPCachingTime.Value()
300 avgTimeNano := float64(timeNano) / float64(count)
301 avgTimeMs := avgTimeNano / 1e6
302 timeMS := timeNano / 1e6
303
304 _, _ = fmt.Fprintf(os.Stdout, "timestamp,")
305 _, _ = fmt.Fprintf(os.Stdout, "high_seq_feed,")
306 _, _ = fmt.Fprintf(os.Stdout, "pending_seq_len,")
307 _, _ = fmt.Fprintf(os.Stdout, "high_seq_stable,")
308 _, _ = fmt.Fprintf(os.Stdout, "current_skipped_seq_count,")
309 _, _ = fmt.Fprintf(os.Stdout, "num_skipped_seqs,")
310 _, _ = fmt.Fprintf(os.Stdout, "skipped_sequence_skip_list_nodes,")
311 _, _ = fmt.Fprintf(os.Stdout, "dcp_caching_count,")
312 _, _ = fmt.Fprintf(os.Stdout, "dcp_caching_time,")
313 _, _ = fmt.Fprintf(os.Stdout, "avg_time_per_seq_ms")
314 _, _ = fmt.Fprintf(os.Stdout, "\n")
315
316 // print end of run stats
317 _, _ = fmt.Fprintf(os.Stdout, "%d,", time.Now().Unix())
318 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Database().HighSeqFeed.Value())
319 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().PendingSeqLen.Value())
320 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().HighSeqStable.Value())
321 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().NumCurrentSeqsSkipped.Value())
322 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().NumSkippedSeqs.Value())
323 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().SkippedSequenceSkiplistNodes.Value())
324 _, _ = fmt.Fprintf(os.Stdout, "%d,", count)
325 _, _ = fmt.Fprintf(os.Stdout, "%d,", timeMS)
326 _, _ = fmt.Fprintf(os.Stdout, "%f", avgTimeMs)
327 _, _ = fmt.Fprintf(os.Stdout, "\n")
328}
329
330func csvStats(ctx context.Context, dbContext *db.DatabaseContext) {
331 ticker := time.NewTicker(1 * time.Second)

Callers 1

mainFunction · 0.85

Calls 4

UpdateCalculatedStatsMethod · 0.80
CacheMethod · 0.80
ValueMethod · 0.45
DatabaseMethod · 0.45

Tested by

no test coverage detected