-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISCodeSamples1.cpp
More file actions
95 lines (81 loc) · 1.71 KB
/
ISCodeSamples1.cpp
File metadata and controls
95 lines (81 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// ISCodeSamples1.cpp
//
//
// Created by Lillie on 3/23/15.
//
//
#include "ISCodeSamples1.h"
#include <cmath>
#include <iostream>
#include "sim_api.h"
#define NUMITEMS 10000
#define REPS 10
//Implementation with member function
//void function_plus(double* d){
// *d = *d + 1;
//}
//Virtual Function Implementation
//class sample_base {
//public:
// virtual void vfunction_plus(double *d) = 0;
//};
//class sample_inherit1 : public sample_base{
//public:
// void vfunction_plus(double *d){
// *d = *d + 1;
// }
//};
class sample_member{
double x;
public:
void update(){
x++;
}
virtual void unused(){
x++;
}
};
class sample_virtual{
double x;
public:
virtual void update(){
x++;
}
};
void run_member(sample_member* sample_array){
for (int i=0; i<REPS; i++){
for (int j=0; j<NUMITEMS; j++){
sample_array[j].update();
}
}
}
void run_virtual(sample_virtual* sample_array){
for (int i=0; i<REPS; i++){
for (int j=0; j<NUMITEMS; j++){
sample_array[j].update();
}
}
}
//run both
int main(int argc, const char * argv[]) {
// double sample_array[1000];
// sample_base* vsample_array[1000];
// for (int i=0; i<1000; ++i){
// sample_array[i]=(double) i*1.5;
// vsample_array[i] = new sample_inherit1();
// }
// for (int i=0; i<1000; ++i){
// function_plus(&sample_array[i]);
// }
// for (int i=0; i<1000; ++i){
// vsample_array[i]->vfunction_plus(&sample_array[i]);
// }
// return 0;
// sample_member member[NUMITEMS];
sample_virtual virt[NUMITEMS];
SimRoiStart();
// run_member(member);
run_virtual(virt);
SimRoiEnd();
}