Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C8F9B2.B19B2AEC" ------_=_NextPart_002_01C8F9B2.B19B2AEC Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, I'd like to ask a question about oprofile results I'm getting for a very simple program, looper.c, which I have attached. As you can see, the looper program runs an infinite loop, and should spend 2/3 of the time inside the if-else clause on line 9, and 1/3 of this time on line 12. I compiled this program and ran oprofile using the following commands: =20 gcc -g -o looper looper.c opcontrol --start ./looper [wait 5-10 minutes] opcontrol --stop opannotate -s -a looper =20 Attached is the output from running opannotate (output2.txt). Also attached is the output from doing the same process, but after changing line 8 of looper.c to=20 if (x % 3 =3D=3D 0) { (output.txt) =20 As you can see from the output, in both trials, the vast majority of the samples made during the if-else clause are attributed to line 12. Although in output.txt line 12 should only see twice as many samples as line 9, and in output.txt line 9 should see twice as many as line 12, we get these results. What could be causing this? Poor compiler optimizations or disparities in times for instructions can be ruled out; as the output also shows, the only difference between the assembly generated by the two files is a "jne" instead of a "je" where the if-logic ends. The only difference between line 9 and line 12, in assembly, is a jump, so what is causing the huge difference in processor usage? =20 Thanks for any help you can give.=20 =20 Aaron Yoshitake Office Phone: (760) 931-4468 Cell Phone: (510) 225-8187 =20 ------_=_NextPart_002_01C8F9B2.B19B2AEC Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello, I’d like to ask a = question about oprofile results I’m getting for a very simple program, = looper.c, which I have attached.

As you can see, the looper program = runs an infinite loop, and should spend 2/3 of the time inside the if-else = clause on line 9, and 1/3 of this time on line 12.

I compiled this program and ran = oprofile using the following commands:

 

gcc –g –o looper = looper.c

opcontrol = --start

./looper

[wait 5-10 = minutes]

opcontrol = --stop

opannotate -s -a = looper

 

Attached is the output from running = opannotate (output2.txt). Also attached is the output from doing the same process, = but after changing line 8 of looper.c to

if (x % 3 =3D=3D 0) = {

(output.txt)

 

As you can see from the output, in = both trials, the vast majority of the samples made during the if-else clause = are attributed to line 12. Although in output.txt line 12 should only see = twice as many samples as line 9, and in output.txt line 9 should see twice as = many as line 12, we get these results.

What could be causing this? Poor = compiler optimizations or disparities in times for instructions can be ruled out; = as the output also shows, the only difference between the assembly generated by = the two files is a “jne” instead of a “je” where the if-logic ends. The only difference between line 9 and line 12, in = assembly, is a jump, so what is causing the huge difference in processor = usage?

 

Thanks for any help you can give. =

 

Aaron Yoshitake

Office Phone: (760) = 931-4468

Cell Phone: (510) = 225-8187

 

------_=_NextPart_002_01C8F9B2.B19B2AEC--