update to latest gpt model
This commit is contained in:
31
cmd/rateTest/rate.go
Normal file
31
cmd/rateTest/rate.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
RPM int
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func main() {
|
||||
r := Rate{RPM: 10}
|
||||
for i := 0; i < 10; i++ {
|
||||
go func(j int) {
|
||||
r.RateLimit()
|
||||
fmt.Println("Rate limiting")
|
||||
}(i)
|
||||
}
|
||||
time.Sleep(time.Minute)
|
||||
}
|
||||
|
||||
func (r *Rate) RateLimit() {
|
||||
// Lock for the fraction of a minute based on RPM
|
||||
r.mu.Lock()
|
||||
// Unlock after the fraction of a minute
|
||||
time.Sleep(time.Minute / time.Duration(r.RPM))
|
||||
r.mu.Unlock()
|
||||
}
|
Reference in New Issue
Block a user