开发者

Good math functions that stress the CPU

Anyone know any good math functions that causes a lot of load on the CPU. I am wanting to create a simple program the just creates load for 开发者_Go百科X amount of seconds while another program monitors it. I'm just looking for functions, not actual stress testing programs.


The Computer Language Benchmark Game has quite a few benchmarks, many of which are math-based. It's a good source because the source code for each algorithm is included and there are implementations of each benchmark in dozens of languages. That way, you can just use the implementation in whatever language you're comfortable compiling and running.


Try the Lucas-Lehmer primality test. It's what's used in the Prime95 executable, and Prime95's fairly standard for CPU stress testing.


A naive implementation of Fibonacci? Something like:

let fib = Seq.unfold(fun (p, c) -> Some((p, c), (c, p+c))) (1,1)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜