Skip to content

Commit cc5c80b

Browse files
committed
Agon bench 1.04
1 parent 1fe372c commit cc5c80b

File tree

4 files changed

+58
-143
lines changed

4 files changed

+58
-143
lines changed

agon-bench/bin/agon-bench.bin

504 Bytes
Binary file not shown.

agon-bench/bin/agon-bench.map

-124
This file was deleted.

agon-bench/makefile

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CXXFLAGS = -Wall -Wextra -Oz
1111

1212
BSSHEAP_LOW=060000
1313
BSSHEAP_HIGH=070000
14+
STACK_HIGH=080000
1415
# ----------------------------
1516

1617
include $(shell cedev-config --makefile)

agon-bench/src/main.c

+57-19
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@ volatile int32_t count = 0;
1010
// vblank.asm
1111
extern void vblank_handler();
1212
extern void fast_vdu(uint8_t *data, int len);
13+
// misc.asm
14+
extern uint8_t getsysvar_gp(void);
15+
extern void delay_1sec(void);
1316

1417
// called from vblank_handler
1518
void on_vblank()
1619
{
1720
count++;
1821
}
1922

23+
static void vdu_gp(uint8_t msg)
24+
{
25+
putch(23); // Send a general poll packet
26+
putch(0);
27+
putch(0x80);
28+
putch(msg);
29+
}
30+
2031
#define AGON_CLK 18.432f
2132

2233
#define PUSH_ALL "\tpush af\n" \
@@ -33,28 +44,21 @@ void on_vblank()
3344
"\tpop af\n"
3445

3546
int main() {
36-
printf("Agon Bench 1.03\n");
47+
// mode 0: make sure we have a 60hz mode for timing
48+
putch(22); putch(0);
49+
50+
printf("Agon Bench 1.04\n");
3751
printf("===============\n\n");
3852
vblank_handler_t old_handler = mos_setintvector(0x32, &vblank_handler);
3953

4054
{
4155
for (count=-1; count; ) {} // clear counter and let current frame finish
42-
int iters = 0;
43-
while (count < 60) {
44-
iters++;
45-
}
46-
printf("%d C loop iters per second (%.3f MHz ez80 equivalent)\n", iters, AGON_CLK * (float)iters / 292668.0f);
47-
}
48-
{
49-
for (count=-1; count; ) {} // clear counter and let current frame finish
50-
int iters = 0;
51-
while (count < 60) {
52-
asm(" mlt bc\n"
53-
:::"bc");
54-
iters++;
55-
}
56-
printf("%d C loop mlt iters per second (%.3f MHz ez80 equivalent)\n", iters, AGON_CLK * (float)iters / 236407.0f);
56+
delay_1sec(); // should really be 1 second if 18.432MHz cpu
57+
delay_1sec();
58+
printf("ez80 frequency: %.3f MHz\n", 2 * AGON_CLK * 60.0f / count);
5759
}
60+
printf("\n");
61+
5862
{
5963
for (count=-1; count; ) {} // clear counter and let current frame finish
6064
int iters = 0;
@@ -66,15 +70,34 @@ int main() {
6670
);
6771
iters++;
6872
}
69-
printf("%d MOS calls (%.2f x Agon Light)\n", iters, (float)iters / 77478.0f);
73+
printf("Syscalls per second %d MOS calls (%.2f x Agon Light)\n", iters, (float)iters / 77478.0f);
7074
}
75+
printf("\n");
76+
77+
{
78+
for (count=-1; count; ) {} // clear counter and let current frame finish
79+
for (int j=0; j<10; j++) {
80+
uint8_t i=0;
81+
while (i<255) {
82+
vdu_gp(i);
83+
while (getsysvar_gp() != i) {}
84+
i++;
85+
}
86+
}
87+
float elapsed = (float)count / 60.0f;
88+
printf("ez80 <-> VDP round-trips per second %.0f\n", 2550.0f / elapsed);
89+
printf("ez80 <-> VDP round-trip latency %.2f ms\n", 1000.0f * elapsed / 2550.0f);
90+
}
91+
92+
7193
{
7294
for (count=-1; count; ) {} // clear counter and let current frame finish
7395
// load 64KiB of junk into the vdp
7496
vdp_load_bitmap(128, 128, (uint32_t*)0x40000);
7597
float elapsed = (float)count / 60.0f;
76-
printf("%.2f seconds to upload 64KiB to VDP (%.2f KiB/sec, %.2f KBit/sec)\n", elapsed, 64.0f / elapsed, 8.0f*64.0f / elapsed);
98+
printf("ez80 to VDP %.2f KiB/sec (%.2f KBit/sec)\n", 64.0f / elapsed, 8.0f*64.0f / elapsed);
7799
}
100+
78101
{
79102
for (count=-1; count; ) {} // clear counter and let current frame finish
80103
// load 64KiB of junk into the vdp
@@ -83,9 +106,24 @@ int main() {
83106
putch(128); putch(0);
84107
fast_vdu((uint8_t*)0x40000, 65536);
85108
float elapsed = (float)count / 60.0f;
86-
printf("%.2f seconds to upload 64KiB to VDP with fast_vdu() (%.2f KiB/sec, %.2f KBit/sec)\n", elapsed, 64.0f / elapsed, 8.0f*64.0f / elapsed);
109+
printf("ez80 to VDP (fast_vdu) %.2f KiB/sec (%.2f KBit/sec)\n", 64.0f / elapsed, 8.0f*64.0f / elapsed);
87110
}
111+
printf("\n");
88112

113+
mos_del("agon-bench.tmp");
114+
{
115+
for (count=-1; count; ) {} // clear counter and let current frame finish
116+
mos_save("agon-bench.tmp", 0xa0000, 65536);
117+
float elapsed = (float)count / 60.0f;
118+
printf("SDCard write %.2f KiB/sec\n", 64.0f / elapsed);
119+
}
120+
{
121+
for (count=-1; count; ) {} // clear counter and let current frame finish
122+
mos_load("agon-bench.tmp", 0xa0000, 65536);
123+
float elapsed = (float)count / 60.0f;
124+
printf("SDCard read %.2f KiB/sec\n", 64.0f / elapsed);
125+
}
126+
mos_del("agon-bench.tmp");
89127

90128
mos_setintvector(0x32, old_handler);
91129

0 commit comments

Comments
 (0)