Questions tagged [cpu-cycles]

90 questions
74
votes
5 answers

How many CPU cycles are needed for each assembly instruction?

I heard there is Intel book online which describes the CPU cycles needed for a specific assembly instruction, but I can not find it out (after trying hard). Could anyone show me how to find CPU cycle please? Here is an example, in the below code,…
George2
  • 44,761
  • 110
  • 317
  • 455
58
votes
2 answers

What is a clock cycle and clock speed?

I have been reading a book about the Computer's Processor. And I came across some of the terms like clock Ticks, clock Cycle and clock Speed that I am finding very difficult to understand. I will be very thankful if someone can clarify this in a…
user7876385
24
votes
4 answers

Why isn't RDTSC a serializing instruction?

The Intel manuals for the RDTSC instruction warn that out of order execution can change when RDTSC is actually executed, so they recommend inserting a CPUID instruction in front of it because CPUID will serialize the instruction stream (CPUID is…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
11
votes
3 answers

c++ practical computational complexity of SQRT()

What is the difference in CPU cycles (or, in essence, in 'speed') between x /= y; and #include x = sqrt(y); EDIT: I know the operations aren't equivalent, I'm just arbitrarily proposing x /= y as a benchmark for x = sqrt(y)
Matt Munson
  • 2,903
  • 5
  • 33
  • 52
11
votes
4 answers

Approximate Number of CPU Cycles for Various Operations

I am trying to find a reference for approximately how many CPU cycles various operations require. I don't need exact numbers (as this is going to vary between CPUs) but I'd like something relatively credible that gives ballpark figures that I could…
colordot
  • 231
  • 1
  • 3
  • 4
10
votes
1 answer

How does this code calculate the number of CPU cycles elapsed?

Taken from this SO thread, this piece of code calculates the number of CPU cycles elapsed running code between lines //1 and //2. $ cat cyc.c #include static __inline__ unsigned long long rdtsc(void) { unsigned long long int x; …
Lazer
  • 90,700
  • 113
  • 281
  • 364
9
votes
5 answers

Determine the critical path in the data flow

In the book Computer Systems: A Programmer's Perspective, the Exercise 5.5 shows a piece of code to compute the value of a polynomial double poly(double a[], double x, int degree) { long int i; double result = a[0]; double xpwr = x; …
pjhades
  • 1,948
  • 2
  • 19
  • 34
7
votes
5 answers

How do I obtain CPU cycle count in Win32?

In Win32, is there any way to get a unique cpu cycle count or something similar that would be uniform for multiple processes/languages/systems/etc. I'm creating some log files, but have to produce multiple logfiles because we're hosting the .NET…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
6
votes
3 answers

Question about cycle counting accuracy when emulating a CPU

I am planning on creating a Sega Master System emulator over the next few months, as a hobby project in Java (I know it isn't the best language for this but I find it very comfortable to work in, and as a frequent user of both Windows and Linux I…
PhilPotter1987
  • 1,306
  • 2
  • 12
  • 20
6
votes
3 answers

What's the relationship between the real CPU frequency and the clock_t in C?

What's the relationship between the real CPU frequency and the clock_t (the unit is clock tick) in C? Let's say I have the below piece of C code which measures the time that CPU consumed for running a for loop. But since the CLOCKS_PER_SEC is a…
Jason Yu
  • 1,886
  • 16
  • 26
6
votes
10 answers

How to set CPU load on a Red Hat Linux box?

I have a RHEL box that I need to put under a moderate and variable amount of CPU load (50%-75%). What is the best way to go about this? Is there a program that can do this that I am not aware of? I am happy to write some C code to make this happen,…
salt.racer
  • 21,903
  • 14
  • 44
  • 51
5
votes
3 answers

Is a mov to a segmentation register slower than a mov to a general purpose register?

Specifically is: mov %eax, %ds Slower than mov %eax, %ebx Or are they the same speed. I've researched online, but have been unable to find a definitive answer. I'm not sure if this is a silly question, but I think it's conceivable modifying a…
Others
  • 2,876
  • 2
  • 30
  • 52
4
votes
2 answers

(n - Multiplication) vs (n/2 - multiplication + 2 additions) which is better?

I have a C program that has n multiplications (single multiplication with n iterations) and I found another logic that has n/2 iterations of (1 multiplication + 2 additions). I know about the complexity that both are of O(n). but in terms of CPU…
Tejas Joshi
  • 197
  • 3
  • 12
4
votes
0 answers

Convert CPU cycles into seconds in C programming

I was trying to figure out if there is any easy method to convert the CPU cycles obtained in C using rdtsc() function into time in seconds. ex:- unsigned long long start, stop; start = rdtsc(); stop = rdtsc(); printf(" CPU CYCLES: %llu\n",…
nk134
  • 43
  • 1
  • 7
4
votes
2 answers

Counting an Intel 8086's clock cycles

I've been working on an Intel 8086 emulator for about a month now. I've decided to start counting cycles to make emulation more accurate and synchronize it correctly with the PIT. The clock cycles used for each instruction are detailed in Intel's…
neat
  • 63
  • 2
  • 8
1
2 3 4 5 6