-
Notifications
You must be signed in to change notification settings - Fork 1
/
geos_perf.h
115 lines (99 loc) · 2.67 KB
/
geos_perf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <stdint.h>
#include "geos_c.h"
#include "geos_perf_config.h"
#define MAXSTRLEN 1024
/**
* 3.9.2 => 309
*/
#define GEOS_VERSION_CMP ((100*GEOS_VERSION_MAJOR)+GEOS_VERSION_MINOR)
/**
* Generate a "skip" callback function with the appropriate name
*/
#define GEOS_PERF_SKIP(callback_name) \
gp_test callback_name(void) { \
gp_test test; \
test.count = 0; \
return test; }
/**
* Each setup/run/clean step in a test is
* a void function of this type.
*/
typedef void (*gp_func)(void);
/**
* Each test file has a gp_config_func() that
* returns a test struct, with the name/metadata
* the functions to run, and a count of the number
* of times to run the main test.
*/
typedef struct {
const char* name;
const char* description;
gp_func func_setup;
gp_func func_run;
gp_func func_cleanup;
uint32_t count;
} gp_test;
/**
* The main test runner tracks time for
* each stage and the number of iterations
* and returns summary statistics for
* each test it runs.
*/
typedef struct {
const char* version;
const char* name;
double setup_time;
double run_time;
double cleanup_time;
uint32_t count;
} gp_result;
/**
* Each test must define a config function
* that produces a test structure for the
* runner to execute. The config function is
* referenced at the top of the geos_perf.c
* file.
*/
typedef gp_test (*gp_config_func)(void);
/**
* Geometry list is a simple expandable array
* of GEOSGeometry pointers.
*/
typedef struct {
GEOSGeometry ** geoms;
size_t ngeoms;
size_t capacity;
} GEOSGeometryList;
void geomlist_init(GEOSGeometryList* gl);
void geomlist_free(GEOSGeometryList* gl);
void geomlist_release(GEOSGeometryList* gl);
void geomlist_print(GEOSGeometryList* gl);
size_t geomlist_push(GEOSGeometryList* gl, GEOSGeometry *g);
size_t geomlist_size(GEOSGeometryList* gl);
GEOSGeometry* geomlist_pop(GEOSGeometryList* gl);
const GEOSGeometry* geomlist_get(GEOSGeometryList* gl, size_t i);
/**
* Read a wkt.gz file, with one wkt geometry per line, gzipped.
* File name is relative to the data directory.
* Geometry list must be initialized by caller.
*/
int read_data_file(const char* file_name, GEOSGeometryList* geoms);
/**
* Read a wkt.gz file into a single geometry. Assumes the
* geometry is on a single line.
*/
GEOSGeometry* read_geometry_file(const char* file_name);
/**
* Write a debugging message to stderr if the debug level
* is higher than the threshold.
*/
void debug_stderr(uint32_t level, const char* fmt, ...);
/**
* GEOS < 3.7 does not have GEOSGeom_createPointFromXY
*/
GEOSGeometry* createPointFromXY(double x, double y);
/**
* Global to hold debug level for this run
* currently unused
*/
extern uint32_t debug_level;