Is there a simple way to generate a constant CPU load in Java? Like generate CPU load at 60%.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Kind of late to the party, but just wanted to share that I created a small open-source client library called FakeLoad which can be used to generate different kinds of system load like CPU, memory, and disk I/O on the fly.
For instance, generating a CPU load of 60% for 30 seconds with FakeLoad can be done like this:
It doesn't provide perfect precision, but it is able to generate quite constant and accurate loads. It is available on Maven Central, so feel free to give it a try :)
I think that's not even possible, because:
Have not tested this, but it might roughly work, to make your application work and sleep in the correct ratio. Something like (pseudocode):
Ok, you asked for a simple way, but ... :)