Add tests to measure protocol latency and throughput
authorMikko Rasa <mikko.rasa@movial.fi>
Thu, 12 Mar 2009 14:36:53 +0000 (16:36 +0200)
committerMikko Rasa <mikko.rasa@movial.fi>
Thu, 12 Mar 2009 14:36:53 +0000 (16:36 +0200)
main.c
synthetic.bench

diff --git a/main.c b/main.c
index 67d33f2..aa028ed 100644 (file)
--- a/main.c
+++ b/main.c
@@ -19,6 +19,8 @@ typedef struct sResult
 } Result;
 
 Result measure(void (*func)(), unsigned batch, unsigned time, MeasureType type);
+void sync();
+void nop();
 void create_destroy_pixmap();
 void create_destroy_picture();
 void fill_rectangle();
@@ -227,6 +229,10 @@ int main(int argc, char **argv)
                                        res=measure(create_destroy_picture, batch, time, type);
                                        XFreePixmap(dpy, pxm);
                                }
+                               else if(!strcmp(delim+1, "sync"))
+                                       res=measure(sync, batch, time, type);
+                               else if(!strcmp(delim+1, "nop"))
+                                       res=measure(nop, batch, time, type);
                                if(res.ops_per_sec>0)
                                {
                                        float score=(res.ops_per_sec-res.error_margin)/weight;
@@ -344,6 +350,16 @@ Result measure(void (*func)(), unsigned batch, unsigned time, MeasureType type)
        }
 }
 
+void sync()
+{
+       XSync(dpy, True);
+}
+
+void nop()
+{
+       XMapWindow(dpy, wnd);
+}
+
 void create_destroy_pixmap()
 {
        Pixmap p=XCreatePixmap(dpy, wnd, width, height, depth);
index e4c8198..9456413 100644 (file)
@@ -4,6 +4,12 @@ batch=10
 
 weight=1.0
 
+Sync:
+       run sync
+
+Nop:
+       run nop
+
 Pixmap 16x16:
        size=16x16
        run pixmap