Does Function pointer make the program slow?
Posted
by drigoSkalWalker
on Stack Overflow
See other posts from Stack Overflow
or by drigoSkalWalker
Published on 2010-03-13T13:45:45Z
Indexed on
2010/03/13
15:35 UTC
Read the original article
Hit count: 220
c
Hi guys. I read about function pointers in C And everyone said that will make my program run slow. Is it true?
I made a program to check it. And I got the same results on both cases. (mesure the time.)
So, is it bad to use fuction pointer? Thanks in advance.
To response for some guys. I said 'run slow' for the time that I have compared on a loop. like this.
int end = 1000; int i = 0;
while (i < end) { fp = func; fp (); }
When you execute this, i got the same time if I execute this.
while (i < end) { func (); }
So I think that function pointer have no difference of time and it don't make a program run slow as many people said.
© Stack Overflow or respective owner