root/trunk/benchmark.c

Revision 36, 1.8 KB (checked in by mike, 5 years ago)

Added a couple optimizations

Line 
1/*
2 * Copyright (C) 2007 Michael Lewis
3 * Author: Mike Lewis <mikelikespie@gmail.com>
4 *
5 * This work is provide AS IS, and has no warranty.
6 * The author is NOT responsible for anything that happens
7 * due to use of this code, either using it or running it on
8 * your system
9 */
10#include <xmmintrin.h>
11#include <emmintrin.h>
12
13#include <stdlib.h>
14#include <stdio.h>
15
16
17#include "types.h"
18#include "helpers.h"
19#include "block.h"
20
21
22
23
24int main( int argc, char** argv) {
25    int i;
26    int width = 10, height = 10;
27    int iterations = 10000;
28
29    int temp_dim;
30    for( i = 0; i < argc; i++ ) {
31        if( !strcmp( "-h", argv[i] ) && i + 1 < argc  ){
32            temp_dim = atoi( argv[i+1] );
33            i++;
34            if( temp_dim ) {
35                height = temp_dim;
36            }
37        } else if( !strcmp( "-w", argv[i] ) && i + 1 < argc  ){
38            temp_dim = atoi( argv[i+1] );
39            i++;
40            if( temp_dim ) {
41                width = temp_dim;
42            }
43        } else if( !strcmp( "-i", argv[i] ) && i + 1 < argc  ){
44            temp_dim = atoi( argv[i+1] );
45            i++;
46            if( temp_dim ) {
47                iterations = temp_dim;
48            }
49        }
50    }
51
52
53    llife_world my_world = allocate_world( width, height );
54    *(my_world->blocks) = allocate_block();
55    printf( "%x\n", *my_world->blocks );
56
57    set_bit_in_world( my_world, 100-50, 100-50 );
58    set_bit_in_world( my_world, 100-51, 100-50 );
59    set_bit_in_world( my_world, 100-52, 100-50 );
60    set_bit_in_world( my_world, 100-54, 100-50 );
61
62    set_bit_in_world( my_world, 100-50, 100-51 );
63
64    set_bit_in_world( my_world, 100-53, 100-52 );
65    set_bit_in_world( my_world, 100-54, 100-52 );
66
67    set_bit_in_world( my_world, 100-51, 100-53 );
68    set_bit_in_world( my_world, 100-52, 100-53 );
69    set_bit_in_world( my_world, 100-54, 100-53 );
70
71    set_bit_in_world( my_world, 100-50, 100-54 );
72    set_bit_in_world( my_world, 100-52, 100-54 );
73    set_bit_in_world( my_world, 100-54, 100-54 );
74    int k;
75    for(  k = 0; k < iterations; k++ ) {
76        worldCycle( my_world);
77    }
78
79    return 0;   
80}
Note: See TracBrowser for help on using the browser.