~ft/libpt

593e92262295ade7fd961f24501a672cab81844a — Sigrid Haflínudóttir a month ago b6cca1b
add more stats and print average
1 files changed, 8 insertions(+), 7 deletions(-)

M test.c
M test.c => test.c +8 -7
@@ 276,16 276,15 @@ prepare(Sfont *f, char *s)
	Rectangle rect, o;
	Memimage *mi;
	uchar *p;
	uvlong t[8][2], dt;
	uvlong t[8][3];

	memset(t, 0, sizeof(t));
#define STATSTART(i) do{ \
	t[i][0] = nanosec(); \
}while(0)
#define STATEND(i) do{ \
	dt = (nanosec()-t[i][0])/1000ULL; \
	if(t[i][1] < dt) \
		t[i][1] = dt; \
	t[i][1] += nanosec()-t[i][0]; \
	t[i][2]++; \
}while(0)

STATSTART(0);


@@ 300,10 299,10 @@ STATSTART(0);
	base = 0;

	for(i = 0; s[i]; i += n){
STATSTART(1);
		n = chartorune(&r, s+i);
		glyph = code2glyph(f, r);

STATSTART(1);
		if(prevglyph > 0 && glyph > 0 && r != '\n')
			x += stbtt_GetGlyphKernAdvance(&f->fi, prevglyph, glyph) * f->scale;
		shift = x - floor(x);


@@ 344,11 343,13 @@ STATSTART(3);
				&x0, &y0, nil, nil
			);
STATEND(3);
STATSTART(4);
			o.min.x = floor(x) + x0;
			o.min.y = base + f->asc*f->scale + y0;
			memimagedraw(mi, o, f->white, ZP, f->g, ZP, DoutS);
			stbtt_GetGlyphHMetrics(&f->fi, glyph, &adv, &leftb);
			x += adv * f->scale;
STATEND(4);
		}else
			glyph = 0;
		prevglyph = glyph;


@@ 386,9 387,9 @@ STATEND(3);
STATEND(0);

	s = info;
	s += sprint(s, "%dpx prefilter=%d gamma=%.2g ", (int)f->height, prefilter, gamma);
	s += sprint(s, "%dpx prefilter=%d gamma=%.3g ", (int)f->height, prefilter, gamma);
	for(i = 0; i < 4; i++)
		s = seprint(s, info+sizeof(info), "%zd ", t[i][1]);
		s = seprint(s, info+sizeof(info), "%zd(%zd) ", (t[i][1]/t[i][2])/1000ULL, t[i][2]);
}

void