aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_test.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-02-11 22:48:25 +1000
committerDavid Walter Seikel2012-02-11 22:48:25 +1000
commit754815bc951bcd204e74acdefe6612491429e190 (patch)
tree0a4bc93ebb9bfceee397c60af18da918d6c822ad /LuaSL/src/LuaSL_test.c
parentCleaner quitting (letting the loop actually run), and clean up unused function. (diff)
downloadSledjHamr-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 '')
-rw-r--r--LuaSL/src/LuaSL_test.c71
1 files changed, 51 insertions, 20 deletions
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
5typedef 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
4static Eina_Strbuf *clientStream; 17static Eina_Strbuf *clientStream;
18static int scriptCount = 0;
19static float compileTime = 0.0;
5 20
6static const char *names[] = 21static 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
71static void common_dirList(gameGlobals *game, const char *name, const char *path, const char *type, const char *command) 86static 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
87static 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
94static 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
101static Eina_Bool _quit_timer_cb(void *data) 110static 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)))