Advertisement
Ollie920049

benchmark.q

May 3rd, 2012
1,029
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. / =====================================================================================
  2. /      Filename:  benchmark.q
  3. /   Description:  Load Several C/C++ regular expression libraries into Q
  4. /                 Test the libraries on a various hex strings increasing in length
  5. /                 Test the hex strings on an increasing number of signatures
  6.  
  7. /       Version:  1.0
  8. /       Created:  23/02/12 15:42:19
  9.  
  10. /        Author:  Oliver Fletcher, ttolf@lboro.ac.uk
  11. /    University:  Loughborough University
  12. / =====================================================================================
  13.  
  14. regexp:`pcre 2:(`regexp;2);                      / Load pcre re2 boost xpressive
  15. regexr:`re2 2:(`regexp;2);                        
  16. regexb:`boost 2:(`regexp;2);                      
  17. regexx:`xpressive 2:(`regexp;2);                  
  18.  
  19. hex:"0123456789abcdef";                          / used to randomly generate hex data
  20. kb10:20000?hex;                                  / create strings of length 10kb 100kb
  21. kb100:200000?hex;                                / and 1mb
  22. mb1:2000000?hex;
  23.  
  24. v1:1#virus_sigs[`hexsig];                        / select 1,25...100 hex signatures
  25. v2:25#virus_sigs[`hexsig];
  26. v3:50#virus_sigs[`hexsig];
  27. v4:75#virus_sigs[`hexsig];
  28. v5:100#virus_sigs[`hexsig];
  29.  
  30. 1 "benchmarking pcre library";                    / begin bench marking pcre saving
  31.                                                  / the time and save to table pcre
  32. a1:value "\\t regexp[kb10;]peach v1";
  33. a2:value "\\t regexp[kb10;]peach v2";
  34. a3:value "\\t regexp[kb10;]peach v3";
  35. a4:value "\\t regexp[kb10;]peach v4";
  36. a5:value "\\t regexp[kb10;]peach v5";
  37. a6:value "\\t regexp[kb100;]peach v1";
  38. a7:value "\\t regexp[kb100;]peach v2";
  39. a8:value "\\t regexp[kb100;]peach v3";
  40. a9:value "\\t regexp[kb100;]peach v4";
  41. a10:value "\\t regexp[kb100;]peach v5";
  42. a11:value "\\t regexp[mb1;]peach v1";
  43. a12:value "\\t regexp[mb1;]peach v2";
  44. a13:value "\\t regexp[mb1;]peach v3";
  45. a14:value "\\t regexp[mb1;]peach v4";
  46. a15:value "\\t regexp[mb1;]peach v5";
  47. pcre:([]file:(`10kb`100kb`1mb);sig1:(a1;a6;a11);sig25:(a2;a7;a12);sig50:(a3;a8;a13);sig75:(a4;a9;a14);sig100:(a5;a10;a15));
  48.  
  49. 1 "benchmarking re2 library";                    / begin bench marking pcre saving
  50.                                                  / the time and save to table pcre
  51. a1:value "\\t regexr[kb10;]peach v1";
  52. a2:value "\\t regexr[kb10;]peach v2";
  53. a3:value "\\t regexr[kb10;]peach v3";
  54. a4:value "\\t regexr[kb10;]peach v4";
  55. a5:value "\\t regexr[kb10;]peach v5";
  56. a6:value "\\t regexr[kb100;]peach v1";
  57. a7:value "\\t regexr[kb100;]peach v2";
  58. a8:value "\\t regexr[kb100;]peach v3";
  59. a9:value "\\t regexr[kb100;]peach v4";
  60. a10:value "\\t regexr[kb100;]peach v5";
  61. a11:value "\\t regexr[mb1;]peach v1";
  62. a12:value "\\t regexr[mb1;]peach v2";
  63. a13:value "\\t regexr[mb1;]peach v3";
  64. a14:value "\\t regexr[mb1;]peach v4";
  65. a15:value "\\t regexr[mb1;]peach v5";
  66. re2:([]file:(`10kb`100kb`1mb);sig1:(a1;a6;a11);sig25:(a2;a7;a12);sig50:(a3;a8;a13);sig75:(a4;a9;a14);sig100:(a5;a10;a15));
  67.  
  68. "benchmarking boost library"                      / begin bench marking pcre saving
  69.                                                  / the time and save to table pcre
  70. a1:value "\\t regexb[kb10;]peach v1";
  71. a2:value "\\t regexb[kb10;]peach v2";
  72. a3:value "\\t regexb[kb10;]peach v3";
  73. a4:value "\\t regexb[kb10;]peach v4";
  74. a5:value "\\t regexb[kb10;]peach v5";
  75. a6:value "\\t regexb[kb100;]peach v1";
  76. a7:value "\\t regexb[kb100;]peach v2";
  77. a8:value "\\t regexb[kb100;]peach v3";
  78. a9:value "\\t regexb[kb100;]peach v4";
  79. a10:value "\\t regexb[kb100;]peach v5";
  80. a11:value "\\t regexb[mb1;]peach v1";
  81. a12:value "\\t regexb[mb1;]peach v2";
  82. a13:value "\\t regexb[mb1;]peach v3";
  83. a14:value "\\t regexb[mb1;]peach v4";
  84. a15:value "\\t regexb[mb1;]peach v5";
  85. boost:([]file:(`10kb`100kb`1mb);sig1:(a1;a6;a11);sig25:(a2;a7;a12);sig50:(a3;a8;a13);sig75:(a4;a9;a14);sig100:(a5;a10;a15));
  86.  
  87. "benchmarking xpressive library"                  / begin bench marking pcre saving
  88.                                                  / the time and save to table pcre
  89. a1:value "\\t regexx[kb10;]peach v1";
  90. a2:value "\\t regexx[kb10;]peach v2";
  91. a3:value "\\t regexx[kb10;]peach v3";
  92. a4:value "\\t regexx[kb10;]peach v4";
  93. a5:value "\\t regexx[kb10;]peach v5";
  94. a6:value "\\t regexx[kb100;]peach v1";
  95. a7:value "\\t regexx[kb100;]peach v2";
  96. a8:value "\\t regexx[kb100;]peach v3";
  97. a9:value "\\t regexx[kb100;]peach v4";
  98. a10:value "\\t regexx[kb100;]peach v5";
  99. a11:value "\\t regexx[mb1;]peach v1";
  100. a12:value "\\t regexx[mb1;]peach v2";
  101. a13:value "\\t regexx[mb1;]peach v3";
  102. a14:value "\\t regexx[mb1;]peach v4";
  103. a15:value "\\t regexx[mb1;]peach v5";
  104. xpressive:([]file:(`10kb`100kb`1mb);sig1:(a1;a6;a11);sig25:(a2;a7;a12);sig50:(a3;a8;a13);sig75:(a4;a9;a14);sig100:(a5;a10;a15));
  105.  
  106. save `:pcre.txt                                  / save the tables as text to be
  107. save `:re2.txt                                    / manimpulated into graphs
  108. save `:boost.txt
  109. save `:xpressive.txt
Advertisement
RAW Paste Data Copied
Advertisement