Index: dlg.c =================================================================== --- dlg.c (revision 30402) +++ dlg.c (revision 30403) @@ -35,6 +35,8 @@ #include #include "actions_pcb.h" +#define PCB dont_use + static void drc_rlist_pcb2dlg(void); static void rlist_select(pcb_hid_attribute_t *attrib, void *hid_ctx, pcb_hid_row_t *row); @@ -123,13 +125,14 @@ pcb_hid_text_t *txt = atxt->wdata; char *script = txt->hid_get_text(atxt, hid_ctx); pcb_view_list_t *view = calloc(sizeof(pcb_view_list_t), 1); + pcb_board_t *pcb = (pcb_board_t *)pcb_gui->get_dad_hidlib(hid_ctx); - drc_qry_exec(PCB, view, ctx->rule, + drc_qry_exec(pcb, view, ctx->rule, ctx->dlg[ctx->wtype].val.str, ctx->dlg[ctx->wtitle].val.str, ctx->dlg[ctx->wdesc].val.str, script); - drcq_open_view_win(&PCB->hidlib, view); + drcq_open_view_win(&pcb->hidlib, view); free(script); } @@ -484,6 +487,7 @@ const char *script; conf_role_t role; pcb_view_list_t *view; + pcb_board_t *pcb = (pcb_board_t *)pcb_gui->get_dad_hidlib(hid_ctx); rlist_fetch(); rlist_fetch_nd(); @@ -495,8 +499,8 @@ } view = calloc(sizeof(pcb_view_list_t), 1); - drc_qry_exec(PCB, view, row->cell[0], textval(nd, "type"), textval(nd, "title"), textval(nd, "desc"), script); - drcq_open_view_win(&PCB->hidlib, view); + drc_qry_exec(pcb, view, row->cell[0], textval(nd, "type"), textval(nd, "title"), textval(nd, "desc"), script); + drcq_open_view_win(&pcb->hidlib, view); } static void rlist_select(pcb_hid_attribute_t *attrib, void *hid_ctx, pcb_hid_row_t *row) Index: drc_query.c =================================================================== --- drc_query.c (revision 30402) +++ drc_query.c (revision 30403) @@ -51,6 +51,7 @@ #include "../src_plugins/drc_query/conf_internal.c" #include "../src_plugins/query/query.h" +#include "drc_query_stat.c" static const char *drc_query_cookie = "drc_query"; @@ -131,6 +132,8 @@ { const char *scope = NULL; drc_qry_ctx_t qctx; + pcb_drcq_stat_t *st; + double ts, te; if (query == NULL) { pcb_message(PCB_MSG_ERROR, "drc_query: igoring rule with no query string:%s\n", name); @@ -146,8 +149,15 @@ qctx.title = title; qctx.desc = desc; + st = pcb_drcq_stat_get(name); + + ts = pcb_dtime(); pcb_qry_run_script(pcb, query, scope, drc_qry_exec_cb, &qctx); + te = pcb_dtime(); + st->last_run_time = te - ts; + st->sum_run_time += te - ts; + return 0; } @@ -378,6 +388,7 @@ vtp0_uninit(&free_drc_conf_nodes); pcb_remove_actions_by_cookie(drc_query_cookie); + pcb_drcq_stat_uninit(); } static conf_hid_callbacks_t cbs; @@ -385,6 +396,9 @@ int pplg_init_drc_query(void) { PCB_API_CHK_VER; + + pcb_drcq_stat_init(); + pcb_event_bind(PCB_EVENT_DRC_RUN, pcb_drc_query, NULL, drc_query_cookie); vtp0_init(&free_drc_conf_nodes); Index: drc_query_stat.c =================================================================== --- drc_query_stat.c (nonexistent) +++ drc_query_stat.c (revision 30403) @@ -0,0 +1,36 @@ +typedef struct { + const char *name; + double last_run_time; + double sum_run_time; +} pcb_drcq_stat_t; + +static htsp_t pcb_drcq_stat; + +static pcb_drcq_stat_init(void) +{ + htsp_init(&pcb_drcq_stat, strhash, strkeyeq); +} + +static pcb_drcq_stat_uninit(void) +{ + htsp_entry_t *e; + for(e = htsp_first(&pcb_drcq_stat); e != NULL; e = htsp_next(&pcb_drcq_stat, e)) { + pcb_drcq_stat_t *st = e->value; + free(st->name); + free(st); + } + htsp_uninit(&pcb_drcq_stat); +} + +static pcb_drcq_stat_t *pcb_drcq_stat_get(const char *name) +{ + pcb_drcq_stat_t *st = htsp_get(&pcb_drcq_stat, name); + + if (st != NULL) + return st; + + st = calloc(sizeof(pcb_drcq_stat_t), 1); + st->name = pcb_strdup(name); + htsp_set(&pcb_drcq_stat, st->name, st); + return st; +}