Skip to content

Commit

Permalink
Disable stats temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
chubin committed Nov 1, 2021
1 parent 4f7b182 commit b9c8f38
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions cmd/stat.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
package main

import (
"log"
"sync"
"time"
)

type safeCounter struct {
v map[int]int
mux sync.Mutex
}

func (c *safeCounter) inc(key int) {
c.mux.Lock()
c.v[key]++
c.mux.Unlock()
}

// func (c *safeCounter) val(key int) int {
// c.mux.Lock()
// defer c.mux.Unlock()
// return c.v[key]
// import (
// "log"
// "sync"
// "time"
// )
//
// type safeCounter struct {
// v map[int]int
// mux sync.Mutex
// }
//
// func (c *safeCounter) reset(key int) int {
// func (c *safeCounter) inc(key int) {
// c.mux.Lock()
// defer c.mux.Unlock()
// result := c.v[key]
// c.v[key] = 0
// return result
// c.v[key]++
// c.mux.Unlock()
// }
//
// // func (c *safeCounter) val(key int) int {
// // c.mux.Lock()
// // defer c.mux.Unlock()
// // return c.v[key]
// // }
// //
// // func (c *safeCounter) reset(key int) int {
// // c.mux.Lock()
// // defer c.mux.Unlock()
// // result := c.v[key]
// // c.v[key] = 0
// // return result
// // }
//
// var queriesPerMinute safeCounter
//
// func printStat() {
// _, min, _ := time.Now().Clock()
// queriesPerMinute.inc(min)
// log.Printf("Processed %d requests\n", min)
// }

var queriesPerMinute safeCounter

func printStat() {
_, min, _ := time.Now().Clock()
queriesPerMinute.inc(min)
log.Printf("Processed %d requests\n", min)
}

0 comments on commit b9c8f38

Please sign in to comment.