Code: Select all
template
void process_f(int count, float* v) {
float* ptr = v;
for (int i = 0; i < count; i++) {
*ptr = f(*ptr);
ptr++;
}
}
void process_without_f(int count, float* v) {
float* ptr = v;
for (int i = 0; i < count; i++) {
*ptr = (*ptr) * 2.0f + 3.0f;
ptr++;
}
}
inline float mult(float v) { return v * 2.0f + 3.0f; }
int main() {
int count = 1000000000;
float* v = new float[count];
process_f(count, v);
process_without_f(count, v);
delete v;
}
Mobile version