Commit d5ada64
Speed test
Changed files (3)
modifiedbirdfont-test/TestRunner.valamodifiedbirdfont-test/inkscape.svgmodifiedlibbirdfont/Screen.vala
Diff
@@ -1,15 +1,36 @@ using BirdFont;+using Cairo; namespace BirdFont { public class TestRunner : NativeWindow, GLib.Object {- public static void fuzz_test (string[] arg) {- if (arg.length != 3) {- print ("Usage: " + arg[0] + " TEST FILE\n");- print ("TEST parameter can be BF or SVG\n");++ public static void run (string[] args) {+ if (args.length < 2) {+ print_usage (args); Process.exit (0); } + string type = args[1];+ + if (type == "SVG" || type == "BF") {+ fuzz_test (args);+ } else if (type == "speed") {+ speed_test ();+ } else {+ print_usage (args);+ }+ + } + + static void print_usage (string[] args) {+ print ("Usage: " + args[0] + " TEST FILE\n");+ print ("TEST parameter can be BF SVG or speed\n");+ }+ + public static void fuzz_test (string[] arg) {+ return_if_fail (arg.length == 3);+ string type = arg[1]; string file = arg[2]; @@ -26,6 +47,38 @@ public class TestRunner : NativeWindow, GLib.Object { Process.exit (0); } + static void speed_test () {+ Test test_path = new Test.time ("Simple path creation");+ + for (int i = 0; i < 3000; i++) {+ Path p = new Path ();+ for (int j = 0; j < 300; j++) {+ p.add (0, 0);+ }+ }+ + test_path.print ();+ + Test test_cairo = new Test.time ("Simple Cairo");+ + for (int i = 0; i < 3000; i++) {+ ImageSurface s;+ Context c;+ + s = Screen.create_background_surface (1000, 1000);+ c = new Context (s);+ + for (int j = 0; j < 30; j++) {+ c.save ();+ c.rectangle (100, 100, 100, 100);+ c.fill ();+ c.restore ();+ }+ }+ + test_cairo.print (); + }+ public void file_chooser (string title, FileChooser file_chooser_callback, uint flags) { } @@ -128,7 +181,7 @@ public static int main (string[] arg) { runner = new TestRunner (); window.set_native (runner);- TestRunner.fuzz_test (arg);+ TestRunner.run (arg); return 0; }@@ -15,7 +15,7 @@ id="svg2" version="1.1" inkscape:version="0.91 r13725"- sodipodi:docname="drawing.svg">+ sodipodi:docname="inkscape.svg"> <defs id="defs4" /> <sodipodi:namedview@@ -26,10 +26,10 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.49497475"- inkscape:cx="205.26829"- inkscape:cy="569.09246"+ inkscape:cx="624.90426"+ inkscape:cy="811.52907" inkscape:document-units="px"- inkscape:current-layer="layer1"+ inkscape:current-layer="svg2" showgrid="false" inkscape:window-width="1213" inkscape:window-height="734"@@ -48,48 +48,58 @@ </cc:Work> </rdf:RDF> </metadata>-- <g transform="translate(300 200)">- <ellipse rx="250" ry="100" fill="red" />+ <g+ transform="matrix(0.62018265,0,0,1.4545686,946.49759,134.34009)"+ id="g3425">+ <ellipse+ rx="250"+ ry="100"+ id="ellipse3427"+ cx="0"+ cy="0"+ style="fill:#ff0000" /> </g>-- <ellipse transform="translate(900 200) rotate(-30)" - rx="250" ry="100"- fill="none" stroke="blue" stroke-width="20" />-- <circle cx="600" cy="200" r="100"- fill="red" stroke="blue" stroke-width="10" />-- <polygon fill="red" stroke="blue" stroke-width="2" - points="350,75 379,161 469,161 397,215- 423,301 350,250 277,301 303,215- 231,161 321,161" />-- <polygon fill="lime" stroke="blue" stroke-width="1" - points="850,75 958,137.5 958,262.5- 850,325 742,262.6 742,137.5" />-- <polyline fill="none" stroke="blue" stroke-width="3" - points="50,375- 150,375 150,325 250,325 250,375- 350,375 350,250 450,250 450,375- 550,375 550,175 650,175 650,375- 750,375 750,100 850,100 850,375- 950,375 950,25 1050,25 1050,375- 1150,375" />-+ <ellipse+ transform="matrix(0.8660254,-0.5,0.5,0.8660254,0,0)"+ rx="250"+ ry="100"+ id="ellipse3429"+ cx="1324.9127"+ cy="967.88464"+ style="fill:none;stroke:#0000ff;stroke-width:20" />+ <circle+ cx="1331.3505"+ cy="175.75633"+ r="100"+ id="circle3431"+ style="fill:#ff0000;stroke:#0000ff;stroke-width:10" />+ <polygon+ points="379,161 469,161 397,215 423,301 350,250 277,301 303,215 231,161 321,161 350,75 "+ id="polygon3433"+ transform="translate(731.35044,-24.243661)"+ style="fill:#ff0000;stroke:#0000ff;stroke-width:2" />+ <polygon+ points="958,137.5 958,262.5 850,325 742,262.6 742,137.5 850,75 "+ id="polygon3435"+ transform="translate(731.35044,-24.243661)"+ style="fill:#00ff00;stroke:#0000ff;stroke-width:1" />+ <polyline+ points="50,375 150,375 150,325 250,325 250,375 350,375 350,250 450,250 450,375 550,375 550,175 650,175 650,375 750,375 750,100 850,100 850,375 950,375 950,25 1050,25 1050,375 1150,375"+ id="polyline3437"+ transform="translate(731.35044,-24.243661)"+ style="fill:none;stroke:#0000ff;stroke-width:3" /> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"> <path id="path3336"- d="m 530.21436,96.442957 c 0.22955,-2.49294 0.22072,-4.99913 0.23615,-7.50037 0.0759,-3.49913 0.31114,-7.00494 0.69108,-10.48499 0.19569,-2.73094 1.18973,-5.2346 2.38578,-7.66023 1.34792,-2.3572 3.1598,-4.42284 4.87878,-6.51609 4.81231,-5.56814 11.71957,-8.69924 18.21635,-11.93448 1.35154,-0.77198 2.8578,-1.08515 4.31892,-1.54228 1.38128,-0.43215 2.69952,-0.98075 4.09797,-1.37133 3.51161,-0.70063 7.07652,-1.08281 10.64527,-1.36103 3.17741,-0.27503 6.36338,-0.37859 9.55067,-0.43948 33.21929,1.16497 38.71465,48.60176 37.39069,72.693173 -0.13208,3.02811 -0.43859,6.03452 -0.76695,9.04605 -0.38008,3.09515 -0.82911,6.17888 -1.10014,9.28677 -0.21607,2.34566 -0.22316,4.70361 -0.27745,7.05685 -0.73383,8.30678 -1.87854,16.73092 0.0141,24.61604 6.3008,10.40178 13.98933,18.83499 23.79271,23.9935 2.01853,0.89311 3.93853,1.99996 6.01798,2.74894 1.56008,0.54266 2.97671,1.35695 4.4368,2.11118 l -10.54961,6.91182 0,0 c -1.41603,-0.75423 -2.86204,-1.42739 -4.36161,-2.0018 -9.37867,-4.46491 -19.92902,-12.04992 -25.48795,-19.83017 -1.80824,-2.52871 -3.57924,-5.15244 -4.724,-8.05549 -0.71299,-2.84947 -1.34614,-5.72496 -1.18252,-8.68175 -0.008,-7.78416 0.50498,-15.91494 1.14884,-23.31982 0.36378,-3.11371 0.91446,-6.20527 1.14332,-9.33363 0.39488,-2.98018 0.70133,-5.96077 0.77775,-8.9689 0.17449,-2.75094 0.25889,-5.45636 -0.58242,-8.1294 -0.33448,-1.16006 -0.57513,-1.78053 -0.67591,-2.99605 -0.41995,-22.903383 -3.57299,-49.580213 -27.58493,-58.741593 -2.46062,-0.83394 -4.93114,-1.22289 -7.53548,-1.0467 -3.07571,0.0101 -6.15342,0.0774 -9.22111,0.31279 -3.59705,0.34292 -7.20502,0.80902 -10.70619,1.7231 -2.76243,0.88754 -5.56402,1.72663 -8.17464,3.00611 -4.22478,2.20497 -4.33451,2.29504 7.38773,-4.44001 0.48452,-0.27838 -0.95099,0.58917 -1.40182,0.91931 -1.16396,0.8524 -2.14842,1.91104 -3.18083,2.90972 -1.69282,2.02276 -3.37571,4.07297 -4.88132,6.23646 -1.29745,2.29607 -2.42205,4.67462 -2.7175,7.33146 -0.54461,3.40741 -0.77769,6.89464 -0.77396,10.34213 0.0141,2.42092 -9.1e-4,4.84798 0.23615,7.25973 l -11.48213,5.85046 z"+ d="m 903.9708,112.6054 c 0.22955,-2.49294 0.22072,-4.99913 0.23615,-7.50037 0.0759,-3.49913 0.31114,-7.004943 0.69108,-10.484993 0.19569,-2.73094 1.18973,-5.2346 2.38578,-7.66023 1.34792,-2.3572 3.1598,-4.42284 4.87878,-6.51609 4.81231,-5.56814 11.71957,-8.69924 18.21635,-11.93448 1.35154,-0.77198 2.8578,-1.08515 4.31892,-1.54228 1.38128,-0.43215 2.69952,-0.98075 4.09797,-1.37133 3.51161,-0.70063 7.07652,-1.08281 10.64527,-1.36103 3.17741,-0.27503 6.36338,-0.37859 9.55067,-0.43948 33.21929,1.16497 38.71465,48.601763 37.39069,72.693173 -0.13208,3.02811 -0.43859,6.03452 -0.76695,9.04605 -0.38008,3.09515 -0.82911,6.17888 -1.10014,9.28677 -0.21607,2.34566 -0.22316,4.70361 -0.27745,7.05685 -0.73383,8.30678 -1.87854,16.73092 0.0141,24.61604 6.30078,10.40178 13.98938,18.83499 23.79268,23.9935 2.0186,0.89311 3.9386,1.99996 6.018,2.74894 1.5601,0.54266 2.9767,1.35695 4.4368,2.11118 l -10.5496,6.91182 0,0 c -1.416,-0.75423 -2.862,-1.42739 -4.3616,-2.0018 -9.3787,-4.46491 -19.92903,-12.04992 -25.48796,-19.83017 -1.80824,-2.52871 -3.57924,-5.15244 -4.724,-8.05549 -0.71299,-2.84947 -1.34614,-5.72496 -1.18252,-8.68175 -0.008,-7.78416 0.50498,-15.91494 1.14884,-23.31982 0.36378,-3.11371 0.91446,-6.20527 1.14332,-9.33363 0.39488,-2.98018 0.70133,-5.96077 0.77775,-8.9689 0.17449,-2.75094 0.25889,-5.45636 -0.58242,-8.1294 -0.33448,-1.16006 -0.57513,-1.78053 -0.67591,-2.99605 -0.41995,-22.90338 -3.57299,-49.580213 -27.58493,-58.741593 -2.46062,-0.83394 -4.93114,-1.22289 -7.53548,-1.0467 -3.07571,0.0101 -6.15342,0.0774 -9.22111,0.31279 -3.59705,0.34292 -7.20502,0.80902 -10.70619,1.7231 -2.76243,0.88754 -5.56402,1.72663 -8.17464,3.00611 -4.22478,2.20497 -4.33451,2.29504 7.38773,-4.44001 0.48452,-0.27838 -0.95099,0.58917 -1.40182,0.91931 -1.16396,0.8524 -2.14842,1.91104 -3.18083,2.90972 -1.69282,2.02276 -3.37571,4.07297 -4.88132,6.23646 -1.29745,2.29607 -2.42205,4.67462 -2.7175,7.33146 -0.54461,3.40741 -0.77769,6.89464 -0.77396,10.34213 0.0141,2.420923 -9.1e-4,4.847983 0.23615,7.259733 l -11.48213,5.85046 z" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccscccccccccccccccccccccccccccssccccccc" /> <path id="path3338"- d="m 590.62407,128.42627 c -2.87235,-0.55223 -5.75325,-0.23469 -8.63201,0.0356 -3.3226,0.34662 -6.64475,0.67807 -9.962,1.0819 -55.02,9.80749 -43.95719,56.49419 -5.57685,65.93053 2.28604,0.78259 4.3684,1.95945 6.71033,2.58207 50.40294,-4.86553 -0.3861,2.98016 47.21599,-15.86941 l 0,0 c -1.61624,1.08719 -3.00508,2.43643 -4.56508,3.60366 -15.13345,6.20768 -12.48911,15.00919 -46.32017,19.61022 -2.22912,0.16359 -4.51176,0.42763 -6.68128,-0.27092 -2.31813,-0.75589 -4.45734,-1.91593 -6.76549,-2.70385 -2.33965,-0.95913 -4.74318,-1.77659 -6.98725,-2.95342 -47.68005,-22.56126 -22.46711,-69.50933 21.04915,-75.64057 3.85796,-0.76447 7.72173,-1.22449 11.64271,-1.53847 11.77804,-2.16543 23.1665,-0.66046 34.49525,0.14803 2.06008,0.14905 4.10767,0.50696 6.16658,0.57015 -9.97576,9.21189 -19.8907,7.31984 -31.78988,5.41459 z"+ d="m 964.38051,144.58871 c -2.87235,-0.55223 -5.75325,-0.23469 -8.63201,0.0356 -3.3226,0.34662 -6.64475,0.67807 -9.962,1.0819 -55.02,9.80749 -43.95719,56.49419 -5.57685,65.93053 2.28604,0.78259 4.3684,1.95945 6.71033,2.58207 50.40294,-4.86553 -0.3861,2.98016 47.21599,-15.86941 l 0,0 c -1.61624,1.08719 -3.00508,2.43643 -4.56508,3.60366 -15.13345,6.20768 -12.48911,15.00919 -46.32017,19.61022 -2.22912,0.16359 -4.51176,0.42763 -6.68128,-0.27092 -2.31813,-0.75589 -4.45734,-1.91593 -6.76549,-2.70385 -2.33965,-0.95913 -4.74318,-1.77659 -6.98725,-2.95342 -47.68005,-22.56126 -22.46711,-69.50933 21.04915,-75.64057 3.85796,-0.76447 7.72173,-1.22449 11.64271,-1.53847 11.77804,-2.16543 23.1665,-0.66046 34.49525,0.14803 2.06008,0.14905 4.10767,0.50696 6.16658,0.57015 -9.97576,9.21189 -19.8907,7.31984 -31.78988,5.41459 z" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccccccccccccc" /> <rect@@ -97,12 +107,22 @@ id="rect4135" width="120" height="120"- x="535.12256"- y="298.07648" />+ x="1266.473"+ y="273.83282" /> <path- style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:14.50000038;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"- d="m 527.29963,490.71739 131.31983,0"+ style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:14.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"+ d="m 1258.6501,466.47373 131.3198,0" id="path4137" inkscape:connector-curvature="0" /> </g>+ <path+ style="fill:#000000;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+ d="m 28.284271,244.24017 52.527932,-2.0203 50.507627,-131.31983 54.54824,127.27922 62.62945,2.0203 -94.95433,-197.989893 -48.48733,4.04061 z"+ id="path3444"+ inkscape:connector-curvature="0" />+ <path+ style="fill:#000000;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+ d="m 78.791898,179.59041 -6.060915,26.26397 115.157387,-4.04061 -6.06091,-32.32488 z"+ id="path3446"+ inkscape:connector-curvature="0" /> </svg>@@ -16,7 +16,7 @@ using Cairo; namespace BirdFont { -class Screen {+public class Screen { public static double get_scale () { return MainWindow.native_window.get_screen_scale (); }