summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-07 12:12:24 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-07 12:12:24 +0200
commit334f55d25988d2107ebd6ee55ccdae054c19281b (patch)
tree863175fd3a0374b76760c8d2051842abc139868d
parentea50541efea96e12b78c7d17803d90d9715856e8 (diff)
downloadct_sequence-statsik.tar.gz
-rw-r--r--makefile2
-rw-r--r--src/a0.c37
-rw-r--r--src/main.c3
3 files changed, 23 insertions, 19 deletions
diff --git a/makefile b/makefile
index 74feacb..537372d 100644
--- a/makefile
+++ b/makefile
@@ -55,7 +55,7 @@ ifneq ($(run),)
run_cmd := @echo "run $(bin)"
run_cmd += && cd bin
run_cmd += && echo "----------------------------------------------------------------"
- run_cmd += && time ./$(out_file) 100000000
+ run_cmd += && time ./$(out_file) -a0 10000000 > stats
run_cmd += ; echo "----------------------------------------------------------------"
run_cmd += && cd ..
endif
diff --git a/src/a0.c b/src/a0.c
index 620d9f6..77bfcc5 100644
--- a/src/a0.c
+++ b/src/a0.c
@@ -25,14 +25,11 @@ void a0_init(uint64_t n){
}
void a0_loop(uint64_t x0,uint64_t x1){
- uint32_t *freq = malloc(sizeof(uint32_t)*x1);
- uint64_t *avgd = malloc(sizeof(uint64_t)*x1);
- uint32_t *cntd = malloc(sizeof(uint32_t)*x1);
- uint32_t *maxd = malloc(sizeof(uint32_t)*x1);
- memset(freq,0x00,sizeof(uint32_t)*x1);
- memset(avgd,0x00,sizeof(uint64_t)*x1);
- memset(cntd,0x00,sizeof(uint32_t)*x1);
- memset(maxd,0x00,sizeof(uint32_t)*x1);
+ size_t smax = 1000000;
+ uint64_t *freq = calloc(sizeof(uint64_t)*smax,1);
+ uint64_t *avgd = calloc(sizeof(uint64_t)*smax,1);
+ uint64_t *cntd = calloc(sizeof(uint64_t)*smax,1);
+ uint64_t *maxd = calloc(sizeof(uint64_t)*smax,1);
freq[t]++;
uint32_t x1_32 = x1;
@@ -44,19 +41,25 @@ void a0_loop(uint64_t x0,uint64_t x1){
r = m[t];
m[t] = x;
t = r == 0 ? 0 : x-r;
- freq[told]++;
- if(r != 0){
- avgd[told] += t;
- cntd[told]++;
- if(t > maxd[told]) maxd[told] = t;
+
+ if(told < smax){
+ freq[told]++;
+ if(r != 0){
+ avgd[told] += t;
+ cntd[told]++;
+ if(t > maxd[told]) maxd[told] = t;
+ }
}
}
- for(uint32_t x = 0;x < x1;x++){
- printf("%10u %10u (%5.2f%%) %10u %10u\n",
+ double cumpct = 0.0;
+ for(uint32_t x = 0;x < smax;x++){
+ double pct = (double)freq[x]/(double)x1*100.0;
+ cumpct += pct;
+ printf("i %10u freq %10u (cur %5.2f%% cum %5.2f%%) avgd %10.2f maxd %10u\n",
x,
- freq[x],(double)freq[x]/(double)x1*100.0,
- cntd[x] == 0 ? 0 : (uint32_t)(avgd[x]/(uint64_t)cntd[x]),
+ freq[x],pct,cumpct,
+ cntd[x] == 0 ? -1.0 : (double)avgd[x]/(double)cntd[x],
maxd[x]);
}
}
diff --git a/src/main.c b/src/main.c
index 9beefbd..a779309 100644
--- a/src/main.c
+++ b/src/main.c
@@ -65,7 +65,8 @@ int main(int argc,char **argv){
void (*calc)(uint64_t n);
#ifdef _WIN32
- SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
+ //SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
+ SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);
#endif
calc = calc_fast;