Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU Intensive Calculation Examples?

I need a few easily implementable single cpu and memory intensive calculations that I can write in java for a test thread scheduler.

They should be slightly time consuming, but more importantly resource consuming.

Any ideas?

like image 938
MEURSAULT Avatar asked Sep 12 '10 00:09

MEURSAULT


People also ask

What are examples of CPU intensive tasks?

Sorting, search, graph traversal, matrix multiply are all CPU operations, a process is CPU-intensive or not it depends on how much and how frequent are their execution.

What is CPU intensive computation?

Compute-intensive is a term that applies to any computer application that demands a lot of computation, such as meteorology programs and other scientific applications. A similar but distinct term, computer-intensive , refers to applications that require a lot of computers, such as grid computing .

What is CPU intensive and memory intensive?

A processor intensive task is any task that is speed limited by how fast the processor can compute the data. Example: encoding video. A memory intensive task is any task that is speed limited by how fast the memory can feed data to the processor.

Is Java CPU intensive?

So Java is CPU-intensive compared to the same program written in C. Java is not interpreted at runtime, at least not as most people would think of interpretation as being. In any competent JVM, Java bytecode is JITed into native code and then executed. Yes, this is slower than running native code.


1 Answers

A few easy examples of CPU-intensive tasks:

  • searching for prime numbers (involves lots of BigInteger divisions)
  • calculating large factorials e.g. 2000! ((involves lots of BigInteger multiplications)
  • many Math.tan() calculations (this is interesting because Math.tan is native, so you're using two call stacks: one for Java calls, the other for C calls.)
like image 53
dogbane Avatar answered Sep 21 '22 04:09

dogbane