B
B
beduin012017-10-08 09:42:32
Programming
beduin01, 2017-10-08 09:42:32

What is the most time consuming operation on the CPU?

You need to simulate some kind of blocking operation. I think some kind of calculation in the loop would be a good option. Question. What is better to count so that the CPU works longer?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
A
Arseniy Efremov, 2017-10-08
@arusef

sleep(1000)

J
jcmvbkbc, 2017-10-08
@jcmvbkbc

What is better to count so that the CPU works longer?

rep nop

R
res2001, 2017-10-08
@res2001

Yes, anything, even an empty loop - the main thing is more iterations. And turn off the optimization options, otherwise the compiler can remove the cycle from the executable file.

G
Griboks, 2017-10-08
@Griboks

a|1=a^a=a*a*a*a*a...=a+a+a+a+a...=a++;a++a;++a;a++;...
And then try to calculate 123546789|1

X
xmoonlight, 2017-10-08
@xmoonlight

Time to interrupt the idle cycle.

�
âš¡ Kotobotov âš¡, 2017-10-08
@angrySCV

all these mathematical operations in loops are very well optimized by the hardware itself, even if you disable optimization in the compiler.
so the most expensive operation is unpredictable, a conditional branch from random data is great for this, the processor will not be able to accurately predict this conditional branch.
well, blocking operations are emulated simply by slips.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question