summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-04-27 12:45:54 +0200
committerBad Diode <bd@badd10de.dev>2021-04-27 12:45:54 +0200
commit3e38d5561d3e2e60f79ec5387f167bb12170c0f9 (patch)
tree51a016a0de13ea687ac6d7aa3e180fb69f4975fe
parentaf05a2979f97d00eab36261374af1eaf2ac3c833 (diff)
downloadgba-experiments-3e38d5561d3e2e60f79ec5387f167bb12170c0f9.tar.gz
gba-experiments-3e38d5561d3e2e60f79ec5387f167bb12170c0f9.zip
Testing the performance of memcpy vs dma_copy routines
-rw-r--r--src/main.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index efd460f..88bc3b8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,18 +40,24 @@ int main(void) {
40 COLOR_BLUE, 40 COLOR_BLUE,
41 COLOR_BLUE, 41 COLOR_BLUE,
42 }; 42 };
43 // These should be equivalent here, but remember that the dma_copy and
44 // dma_fill functions will always work on U32 chunks.
45 //
46 // memcpy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color));
47 // dma_copy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color), 3);
48 43
49 u32 color = COLOR_RED | COLOR_RED << 16; 44 size_t n_iter = 10000;
50 dma_fill(&PAL_BUFFER_SPRITES[0], color, 16 * sizeof(Color), 3); 45 profile_start();
46 for (size_t i = 0; i < n_iter; ++i) {
47 dma_copy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color), 3);
48 }
49 u32 dma_copy_perf = profile_stop();
50
51 profile_start();
52 for (size_t i = 0; i < n_iter; ++i) {
53 memcpy(&PAL_BUFFER_SPRITES[0], colors, 16 * sizeof(Color));
54 }
55 u32 memcpy_perf = profile_stop();
51 56
52 // Initialize text engine. 57 // Initialize text engine.
53 // txt_init(0, COLOR_RED, 0); 58 txt_init(0, COLOR_RED, 0);
54 // txt_printf("TEST"); 59 txt_printf("N. cycles memcpy: %d\n", memcpy_perf);
60 txt_printf("N. cycles dma_copy: %d\n", dma_copy_perf);
55 61
56 int frame_counter = 0; 62 int frame_counter = 0;
57 while(true) { 63 while(true) {
@@ -59,7 +65,7 @@ int main(void) {
59 poll_keys(); 65 poll_keys();
60 66
61 frame_counter++; 67 frame_counter++;
62 update_button_sprites(); 68 // update_button_sprites();
63 }; 69 };
64 70
65 return 0; 71 return 0;