From 75588b85cdca37f1246b3a02bf0dedb085339ac3 Mon Sep 17 00:00:00 2001 From: karl Date: Wed, 21 Oct 2020 18:49:03 +0200 Subject: [PATCH] Comments and minor fix --- main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 5e036ed..0928ec8 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,9 @@ #define DEAD_CELL 0 // '.' in the input data #define NUM_GENERATIONS 250 +// Using this struct seems to be more performant than just passing +// a bool** around functions. However, also adding the neighbor_count +// made performance worse. struct World { World(int size_x, int size_y) : size_x(size_x), size_y(size_y) { data = new bool*[size_y]; @@ -154,15 +157,15 @@ int main() { world_file.close(); - timing->stopSetup(); - timing->startComputation(); - // In this separate array, we keep track of how many live neighbors // a certain cell has. This is because immediately updating based // on the number of neighbors would mess with later calculations // of adjacent cells. int *neighbor_counts = new int[world.size_y * world.size_x]; + timing->stopSetup(); + timing->startComputation(); + // Do some generations for (int i = 0; i < NUM_GENERATIONS; i++) { generation(world, neighbor_counts);