diff options
author | David Walter Seikel | 2012-02-11 22:48:25 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-02-11 22:48:25 +1000 |
commit | 754815bc951bcd204e74acdefe6612491429e190 (patch) | |
tree | 0a4bc93ebb9bfceee397c60af18da918d6c822ad /LuaSL | |
parent | Cleaner quitting (letting the loop actually run), and clean up unused function. (diff) | |
download | SledjHamr-754815bc951bcd204e74acdefe6612491429e190.zip SledjHamr-754815bc951bcd204e74acdefe6612491429e190.tar.gz SledjHamr-754815bc951bcd204e74acdefe6612491429e190.tar.bz2 SledjHamr-754815bc951bcd204e74acdefe6612491429e190.tar.xz |
Track details of scripts in the test harness. Use that to quit them, and print compile times again.
Note - compile times artificially inflated for now, they include waiting for the other scripts to be compiled to.
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL.h | 1 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_test.c | 71 |
2 files changed, 52 insertions, 20 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h index 8f5b58a..6c672e5 100644 --- a/LuaSL/src/LuaSL.h +++ b/LuaSL/src/LuaSL.h | |||
@@ -54,6 +54,7 @@ typedef struct | |||
54 | Evas_Object *bg; // Our background edje, also the game specific stuff. | 54 | Evas_Object *bg; // Our background edje, also the game specific stuff. |
55 | Evas_Object *edje; // The edje of the background. | 55 | Evas_Object *edje; // The edje of the background. |
56 | Ecore_Con_Server *server; | 56 | Ecore_Con_Server *server; |
57 | Eina_Hash *scripts; | ||
57 | int logDom; | 58 | int logDom; |
58 | const char *address; | 59 | const char *address; |
59 | int port; | 60 | int port; |
diff --git a/LuaSL/src/LuaSL_test.c b/LuaSL/src/LuaSL_test.c index c93b8d8..134c536 100644 --- a/LuaSL/src/LuaSL_test.c +++ b/LuaSL/src/LuaSL_test.c | |||
@@ -1,7 +1,22 @@ | |||
1 | 1 | ||
2 | #include "LuaSL.h" | 2 | #include "LuaSL.h" |
3 | 3 | ||
4 | |||
5 | typedef struct | ||
6 | { | ||
7 | char SID[PATH_MAX]; | ||
8 | char fileName[PATH_MAX]; | ||
9 | struct timeval startTime; | ||
10 | float compileTime; | ||
11 | int errors, warnings; | ||
12 | boolean running; | ||
13 | |||
14 | } script; | ||
15 | |||
16 | |||
4 | static Eina_Strbuf *clientStream; | 17 | static Eina_Strbuf *clientStream; |
18 | static int scriptCount = 0; | ||
19 | static float compileTime = 0.0; | ||
5 | 20 | ||
6 | static const char *names[] = | 21 | static const char *names[] = |
7 | { | 22 | { |
@@ -68,43 +83,45 @@ _on_delete(Ecore_Evas *ee __UNUSED__) | |||
68 | ecore_main_loop_quit(); | 83 | ecore_main_loop_quit(); |
69 | } | 84 | } |
70 | 85 | ||
71 | static void common_dirList(gameGlobals *game, const char *name, const char *path, const char *type, const char *command) | 86 | static void dirList_compile(const char *name, const char *path, void *data) |
72 | { | 87 | { |
88 | gameGlobals *game = data; | ||
89 | |||
73 | char buf[PATH_MAX]; | 90 | char buf[PATH_MAX]; |
74 | char *ext = rindex(name, '.'); | 91 | char *ext = rindex(name, '.'); |
75 | 92 | ||
76 | if (ext) | 93 | if (ext) |
77 | { | 94 | { |
78 | if (0 == strcmp(ext, type)) | 95 | if (0 == strcmp(ext, ".lsl")) |
79 | { | 96 | { |
80 | snprintf(buf, sizeof(buf), "%s/%s.%s()\n", path, name, command); | 97 | script *me = calloc(1, sizeof(script)); |
98 | |||
99 | gettimeofday(&me->startTime, NULL); | ||
100 | snprintf(me->SID, sizeof(me->SID), "%s/%s", path, name); | ||
101 | snprintf(me->fileName, sizeof(me->fileName), "%s/%s", path, name); | ||
102 | eina_hash_add(game->scripts, me->SID, me); | ||
103 | snprintf(buf, sizeof(buf), "%s/%s.compile()\n", path, name); | ||
81 | ecore_con_server_send(game->server, buf, strlen(buf)); | 104 | ecore_con_server_send(game->server, buf, strlen(buf)); |
82 | ecore_con_server_flush(game->server); | 105 | ecore_con_server_flush(game->server); |
83 | } | 106 | } |
84 | } | 107 | } |
85 | } | 108 | } |
86 | 109 | ||
87 | static void dirList_compile(const char *name, const char *path, void *data) | ||
88 | { | ||
89 | gameGlobals *game = data; | ||
90 | |||
91 | common_dirList(game, name, path, ".lsl", "compile"); | ||
92 | } | ||
93 | |||
94 | static void dirList_quit(const char *name, const char *path, void *data) | ||
95 | { | ||
96 | gameGlobals *game = data; | ||
97 | |||
98 | common_dirList(game, name, path, ".out", "quit"); | ||
99 | } | ||
100 | |||
101 | static Eina_Bool _quit_timer_cb(void *data) | 110 | static Eina_Bool _quit_timer_cb(void *data) |
102 | { | 111 | { |
103 | gameGlobals *game = data; | 112 | gameGlobals *game = data; |
104 | char buf[PATH_MAX]; | 113 | Eina_Iterator *scripts; |
114 | script *me; | ||
105 | 115 | ||
106 | snprintf(buf, sizeof(buf), "%s/Test sim/objects", PACKAGE_DATA_DIR); | 116 | scripts = eina_hash_iterator_data_new(game->scripts); |
107 | eina_file_dir_list(buf, EINA_TRUE, dirList_quit, game); | 117 | while(eina_iterator_next(scripts, (void **) &me)) |
118 | { | ||
119 | char buf[PATH_MAX]; | ||
120 | |||
121 | snprintf(buf, sizeof(buf), "%s.lua.out.quit()\n", me->SID); | ||
122 | ecore_con_server_send(game->server, buf, strlen(buf)); | ||
123 | ecore_con_server_flush(game->server); | ||
124 | } | ||
108 | 125 | ||
109 | ecore_con_server_send(game->server, ".exit()\n", 8); | 126 | ecore_con_server_send(game->server, ".exit()\n", 8); |
110 | ecore_con_server_flush(game->server); | 127 | ecore_con_server_flush(game->server); |
@@ -153,6 +170,18 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Server_D | |||
153 | PE("The compile of %s failed!", SID); | 170 | PE("The compile of %s failed!", SID); |
154 | else if (0 == strcmp(command, "compiled(true)")) | 171 | else if (0 == strcmp(command, "compiled(true)")) |
155 | { | 172 | { |
173 | script *me = eina_hash_find(game->scripts, SID); | ||
174 | |||
175 | if (me) | ||
176 | { | ||
177 | struct timeval now; | ||
178 | |||
179 | me->compileTime = timeDiff(&now, &me->startTime); | ||
180 | me->running = TRUE; | ||
181 | scriptCount++; | ||
182 | compileTime += me->compileTime; | ||
183 | PI("Average compile speed is %f scripts per second", scriptCount / compileTime); | ||
184 | } | ||
156 | PD("The compile of %s worked, running it now.", SID); | 185 | PD("The compile of %s worked, running it now.", SID); |
157 | snprintf(buf, sizeof(buf), "%s.lua.out.start()\n", SID); | 186 | snprintf(buf, sizeof(buf), "%s.lua.out.start()\n", SID); |
158 | ecore_con_server_send(game->server, buf, strlen(buf)); | 187 | ecore_con_server_send(game->server, buf, strlen(buf)); |
@@ -200,6 +229,8 @@ int main(int argc, char **argv) | |||
200 | if (eina_init()) | 229 | if (eina_init()) |
201 | { | 230 | { |
202 | loggingStartup(&game); | 231 | loggingStartup(&game); |
232 | game.scripts = eina_hash_string_superfast_new(NULL); | ||
233 | |||
203 | if (ecore_con_init()) | 234 | if (ecore_con_init()) |
204 | { | 235 | { |
205 | if ((game.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) | 236 | if ((game.server = ecore_con_server_connect(ECORE_CON_REMOTE_TCP, game.address, game.port, &game))) |