•_timed
This commit is contained in:
parent
dd3c420bf3
commit
54abc94cad
@ -275,7 +275,7 @@ B withFill(B x, B fill) { // consumes both
|
|||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
base:
|
base:;
|
||||||
B r = m_arr(fsizeof(FillArr,a,B,ia), t_fillarr);
|
B r = m_arr(fsizeof(FillArr,a,B,ia), t_fillarr);
|
||||||
arr_shCopy(r, x);
|
arr_shCopy(r, x);
|
||||||
c(FillArr,r)->fill = fill;
|
c(FillArr,r)->fill = fill;
|
||||||
|
|||||||
4
src/h.h
4
src/h.h
@ -126,12 +126,12 @@ char* format_pf(u8 u) {
|
|||||||
}
|
}
|
||||||
enum PrimMd1 {
|
enum PrimMd1 {
|
||||||
pm1_none,
|
pm1_none,
|
||||||
pm1_tbl, pm1_each, pm1_fold, pm1_scan, pm1_const, pm1_swap, // md1.c
|
pm1_tbl, pm1_each, pm1_fold, pm1_scan, pm1_const, pm1_swap, pm1_timed, // md1.c
|
||||||
};
|
};
|
||||||
char* format_pm1(u8 u) {
|
char* format_pm1(u8 u) {
|
||||||
switch(u) {
|
switch(u) {
|
||||||
default: case pf_none: return"(unknown 1-modifier)";
|
default: case pf_none: return"(unknown 1-modifier)";
|
||||||
case pm1_tbl:return"⌜"; case pm1_each:return"¨"; case pm1_fold:return"´"; case pm1_scan:return"`"; case pm1_const:return"˙"; case pm1_swap:return"˜";
|
case pm1_tbl:return"⌜"; case pm1_each:return"¨"; case pm1_fold:return"´"; case pm1_scan:return"`"; case pm1_const:return"˙"; case pm1_swap:return"˜"; case pm1_timed:return"•_timed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enum PrimMd2 {
|
enum PrimMd2 {
|
||||||
|
|||||||
20
src/md1.c
20
src/md1.c
@ -188,14 +188,30 @@ B swap_c1(B d , B x) { return c2(c(Md1D,d)->f, inc(x), x); }
|
|||||||
B swap_c2(B d, B w, B x) { return c2(c(Md1D,d)->f, x , w); }
|
B swap_c2(B d, B w, B x) { return c2(c(Md1D,d)->f, x , w); }
|
||||||
|
|
||||||
|
|
||||||
|
B timed_c2(B d, B w, B x) { B f = c(Md1D,d)->f;
|
||||||
|
i64 am = o2i64(w);
|
||||||
|
for (i64 i = 0; i < am; i++) inc(x);
|
||||||
|
dec(x);
|
||||||
|
u64 sns = nsTime();
|
||||||
|
for (i64 i = 0; i < am; i++) dec(c1(f, x));
|
||||||
|
u64 ens = nsTime();
|
||||||
|
return m_f64((ens-sns)/(1e9*am));
|
||||||
|
}
|
||||||
|
B timed_c1(B d, B x) { B f = c(Md1D,d)->f;
|
||||||
|
u64 sns = nsTime();
|
||||||
|
dec(c1(f, x));
|
||||||
|
u64 ens = nsTime();
|
||||||
|
return m_f64((ens-sns)/1e9);
|
||||||
|
}
|
||||||
|
|
||||||
#define ba(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = NAME##_c2; c(Md1,bi_##NAME)->c1 = NAME##_c1 ; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
#define ba(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = NAME##_c2; c(Md1,bi_##NAME)->c1 = NAME##_c1 ; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
||||||
#define bd(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = NAME##_c2; c(Md1,bi_##NAME)->c1 = c1_invalid; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
#define bd(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = NAME##_c2; c(Md1,bi_##NAME)->c1 = c1_invalid; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
||||||
#define bm(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = c2_invalid;c(Md1,bi_##NAME)->c1 = NAME##_c1 ; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
#define bm(NAME) bi_##NAME = mm_alloc(sizeof(Md1), t_md1BI, ftag(MD1_TAG)); c(Md1,bi_##NAME)->c2 = c2_invalid;c(Md1,bi_##NAME)->c1 = NAME##_c1 ; c(Md1,bi_##NAME)->extra=pm1_##NAME; gc_add(bi_##NAME);
|
||||||
|
|
||||||
void print_md1BI(B x) { printf("%s", format_pm1(c(Md1,x)->extra)); }
|
void print_md1BI(B x) { printf("%s", format_pm1(c(Md1,x)->extra)); }
|
||||||
|
|
||||||
B bi_tbl, bi_each, bi_fold, bi_scan, bi_const, bi_swap;
|
B bi_tbl, bi_each, bi_fold, bi_scan, bi_const, bi_swap, bi_timed;
|
||||||
static inline void md1_init() { ba(tbl) ba(each) ba(fold) ba(scan) ba(const) ba(swap)
|
static inline void md1_init() { ba(tbl) ba(each) ba(fold) ba(scan) ba(const) ba(swap) ba(timed)
|
||||||
ti[t_md1BI].print = print_md1BI;
|
ti[t_md1BI].print = print_md1BI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -168,6 +168,7 @@ BI_FNS0(F);
|
|||||||
static inline void sysfn_init() { BI_FNS1(F) }
|
static inline void sysfn_init() { BI_FNS1(F) }
|
||||||
#undef F
|
#undef F
|
||||||
|
|
||||||
|
B bi_timed;
|
||||||
B sys_c1(B t, B x) {
|
B sys_c1(B t, B x) {
|
||||||
assert(isArr(x));
|
assert(isArr(x));
|
||||||
usz i = 0;
|
usz i = 0;
|
||||||
@ -183,6 +184,7 @@ B sys_c1(B t, B x) {
|
|||||||
else if (eqStr(c, U"primind")) r.a[i] = inc(bi_primInd);
|
else if (eqStr(c, U"primind")) r.a[i] = inc(bi_primInd);
|
||||||
else if (eqStr(c, U"bqn")) r.a[i] = inc(bi_bqn);
|
else if (eqStr(c, U"bqn")) r.a[i] = inc(bi_bqn);
|
||||||
else if (eqStr(c, U"cmp")) r.a[i] = inc(bi_cmp);
|
else if (eqStr(c, U"cmp")) r.a[i] = inc(bi_cmp);
|
||||||
|
else if (eqStr(c, U"timed")) r.a[i] = inc(bi_timed);
|
||||||
else { dec(x); thrM("Unknown system function"); }
|
else { dec(x); thrM("Unknown system function"); }
|
||||||
}
|
}
|
||||||
return harr_fcd(r, x);
|
return harr_fcd(r, x);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user