KO
|
EN
gitlite — search
Search
#python
#java
#python3
#arduino
#golang
#machine-learning
#rust
#html
#flask
#javascript
#seismology
#nodejs
go-cpulimit
★ 20
Open GitHub ↗
Throttle the CPU usage to a maximum
Download README (.md)
Explore Similar Repositories
NppLSP
:
Notepad++ plugin to support the Language Server Protocol (LSP)
AppComponentFramework
:
App 组件化 加载框架,维护一个树状数据结构进行管理、深度优先搜索
stagy
:
Stagy is a tool for quick deployment of staging environments.
containment-patterns
:
pattern combinators extending racket/match to capture 🔗 contexts 📦
snax
:
Decentralized Social Media Overlay
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
go-cpulimit
?
Download (.md)
# go-cpulimit [](https://opensource.org/licenses/MIT) [](https://goreportcard.com/report/github.com/Codehardt/go-cpulimit) [](https://godoc.org/github.com/Codehardt/go-cpulimit) With **go-cpulimit** you can limit the CPU usage of your go program. It provides a function called `Wait()` that holds your program, until the CPU usage is below max CPU usage. You should use this `Wait()` function in as many situations as possible, e.g. on every iteration in a `for loop`. **Warning:** This limiter does not work, if there are insufficient `Wait()` calls. This package requires [github.com/shirou/gopsutil](https://github.com/shirou/gopsutil) *(Copyright (c) 2014, WAKAYAMA Shirou)* to be installed. ## Example ```golang limiter := &cpulimit.Limiter{ MaxCPUUsage: 50.0, // throttle CPU usage to 50% MeasureInterval: time.Millisecond * 333, // measure cpu usage in an interval of 333 ms Measurements: 3, // use the avg of the last 3 measurements } limiter.Start() defer limiter.Stop() for { limiter.Wait() // wait until cpu usage is below 50% /* * do some work */ } ```