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

Function csvStats

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

Source from the content-addressed store, hash-verified

328}
329
330func csvStats(ctx context.Context, dbContext *db.DatabaseContext) {
331 ticker := time.NewTicker(1 * time.Second)
332 defer ticker.Stop()
333 numGoroutines.Add(1)
334 defer numGoroutines.Add(-1)
335 _, _ = fmt.Fprintf(os.Stderr, "timestamp,")
336 _, _ = fmt.Fprintf(os.Stderr, "high_seq_feed,")
337 _, _ = fmt.Fprintf(os.Stderr, "pending_seq_len,")
338 _, _ = fmt.Fprintf(os.Stderr, "high_seq_stable,")
339 _, _ = fmt.Fprintf(os.Stderr, "current_skipped_seq_count,")
340 _, _ = fmt.Fprintf(os.Stderr, "num_skipped_seqs,")
341 _, _ = fmt.Fprintf(os.Stdout, "skipped_sequence_skip_list_nodes,")
342 _, _ = fmt.Fprintf(os.Stderr, "dcp_caching_count,")
343 _, _ = fmt.Fprintf(os.Stderr, "dcp_caching_time,")
344 _, _ = fmt.Fprintf(os.Stderr, "avg_time_per_seq_ms")
345 _, _ = fmt.Fprintf(os.Stderr, "\n")
346
347 for {
348 select {
349 case <-ctx.Done():
350 return
351 case <-ticker.C:
352 dbContext.UpdateCalculatedStats(ctx)
353 dbStats := dbContext.DbStats
354 // calculate here avg time to cache seq in ms
355 count := dbStats.Database().DCPCachingCount.Value()
356 timeNano := dbStats.Database().DCPCachingTime.Value()
357 avgTimeNano := float64(timeNano) / float64(count)
358 avgTimeMs := avgTimeNano / 1e6
359 timeMS := timeNano / 1e6
360 _, _ = fmt.Fprintf(os.Stderr, "%d,", time.Now().Unix())
361 _, _ = fmt.Fprintf(os.Stderr, "%d,", dbStats.Database().HighSeqFeed.Value())
362 _, _ = fmt.Fprintf(os.Stderr, "%d,", dbStats.Cache().PendingSeqLen.Value())
363 _, _ = fmt.Fprintf(os.Stderr, "%d,", dbStats.Cache().HighSeqStable.Value())
364 _, _ = fmt.Fprintf(os.Stderr, "%d,", dbStats.Cache().NumCurrentSeqsSkipped.Value())
365 _, _ = fmt.Fprintf(os.Stderr, "%d,", dbStats.Cache().NumSkippedSeqs.Value())
366 _, _ = fmt.Fprintf(os.Stdout, "%d,", dbStats.Cache().SkippedSequenceSkiplistNodes.Value())
367 _, _ = fmt.Fprintf(os.Stderr, "%d,", count)
368 _, _ = fmt.Fprintf(os.Stderr, "%d,", timeMS)
369 _, _ = fmt.Fprintf(os.Stderr, "%f", avgTimeMs)
370 _, _ = fmt.Fprintf(os.Stderr, "\n")
371 }
372 }
373}
374
375func extractDelays(delayStr string, mode string) ([]time.Duration, error) {
376 var delays []time.Duration

Callers 1

mainFunction · 0.85

Calls 7

DoneMethod · 0.80
UpdateCalculatedStatsMethod · 0.80
CacheMethod · 0.80
StopMethod · 0.65
AddMethod · 0.45
ValueMethod · 0.45
DatabaseMethod · 0.45

Tested by

no test coverage detected