Small tool to benchmark webservers https://redmine.lighttpd.net/projects/weighttp/wiki
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
84 KiB

12 years ago
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Thomas Nagy, 2005-2009
  4. """
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. 3. The name of the author may not be used to endorse or promote products
  14. derived from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
  16. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  19. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  24. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. """
  27. import os, sys
  28. if sys.hexversion<0x203000f: raise ImportError("Waf requires Python >= 2.3")
  29. if 'PSYCOWAF' in os.environ:
  30. try:import psyco;psyco.full()
  31. except:pass
  32. VERSION="1.5.9"
  33. REVISION="d1e0349fc8937631a656fb8ea7e99063"
  34. INSTALL=''
  35. C1='#%'
  36. C2='#$'
  37. cwd = os.getcwd()
  38. join = os.path.join
  39. WAF='waf'
  40. def b(x):
  41. return x
  42. if sys.hexversion>0x300000f:
  43. WAF='waf3'
  44. def b(x):
  45. return x.encode()
  46. def err(m):
  47. print(('\033[91mError: %s\033[0m' % m))
  48. sys.exit(1)
  49. def unpack_wafdir(dir):
  50. f = open(sys.argv[0],'rb')
  51. c = "corrupted waf (%d)"
  52. while 1:
  53. line = f.readline()
  54. if not line: err("run waf-light from a folder containing wafadmin")
  55. if line == b('#==>\n'):
  56. txt = f.readline()
  57. if not txt: err(c % 1)
  58. if f.readline()!=b('#<==\n'): err(c % 2)
  59. break
  60. if not txt: err(c % 3)
  61. txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r'))
  62. import shutil, tarfile
  63. try: shutil.rmtree(dir)
  64. except OSError: pass
  65. try: os.makedirs(join(dir, 'wafadmin', 'Tools'))
  66. except OSError: err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
  67. os.chdir(dir)
  68. tmp = 't.tbz2'
  69. t = open(tmp,'wb')
  70. t.write(txt)
  71. t.close()
  72. try:
  73. t = tarfile.open(tmp)
  74. for x in t: t.extract(x)
  75. t.close()
  76. except:
  77. os.chdir(cwd)
  78. try: shutil.rmtree(dir)
  79. except OSError: pass
  80. err("Waf cannot be unpacked, check that bzip2 support is present")
  81. os.chmod(join('wafadmin','Tools'), 493)
  82. os.unlink(tmp)
  83. if sys.hexversion>0x300000f:
  84. sys.path = [join(dir, 'wafadmin')] + sys.path
  85. import py3kfixes
  86. py3kfixes.fixdir(dir)
  87. os.chdir(cwd)
  88. def test(dir):
  89. try: os.stat(join(dir, 'wafadmin')); return os.path.abspath(dir)
  90. except OSError: pass
  91. def find_lib():
  92. name = sys.argv[0]
  93. base = os.path.dirname(os.path.abspath(name))
  94. #devs use $WAFDIR
  95. w=test(os.environ.get('WAFDIR', ''))
  96. if w: return w
  97. #waf-light
  98. if name.endswith('waf-light'):
  99. w = test(base)
  100. if w: return w
  101. err("waf-light requires wafadmin -> export WAFDIR=/folder")
  102. dir = "/lib/%s-%s-%s/" % (WAF, VERSION, REVISION)
  103. for i in [INSTALL,'/usr','/usr/local','/opt']:
  104. w = test(i+dir)
  105. if w: return w
  106. #waf-local
  107. s = '.%s-%s-%s'
  108. if sys.platform == 'win32': s = s[1:]
  109. dir = join(base, s % (WAF, VERSION, REVISION))
  110. w = test(dir)
  111. if w: return w
  112. #unpack
  113. unpack_wafdir(dir)
  114. return dir
  115. wafdir = find_lib()
  116. w = join(wafdir, 'wafadmin')
  117. t = join(w, 'Tools')
  118. sys.path = [w, t] + sys.path
  119. import Scripting
  120. Scripting.prepare(t, cwd, VERSION, wafdir)
  121. sys.exit(0)
  122. #==>
  123. #BZh91AY&SY���������i������������06 %�S@ da�|���>2Z�ښ�n�f�&�+s�����5�[��;$6�v�l�u963�te����Яm��7֮��۪��U��m�{m�����f���O{(��q7�x��w�w�}�w���uO��{���@_S�}c�g�������e��]���P#$�w��'��J\w�p���O@{��{�Ӿ��O���SOn����t���Ξ�AH@#%� J��($P��I��zw�㽯L��k/�:y�[z9�۶D������ޝ�}�e���^��O4��M������*��v�{�;��}�v��*�}������=�ow}�}��5������*��d�vi�=�&J��ˡe�@Qu���D�(d�fꏦ��͵�������������^��`{���Mz6�����#%���Q�ŋ�� k���>S�xҀ��:��{n���4�vo7��0���]����={;��xm�=]�h��&��yw�s�n��5�fv֎ꆷ�w��;�ǚ�vo���4�Lo�������S�ϕ��}������-�>��w�M�OY����^wݯ��G}Nۋ�{ֶ���}��w��z��B����h#$THP#��^�Tm�u{��]U�K��! I^�^�=������wT�4����t���o����},_t{���Sw���n�}�s<��z[�z{w����s��D���AlY�P"�aץ��Y����u�#%YV��.���sݽ=X����h}�}aM�U�����-�\��Bn�/w��{��c��X��}�ow}+v�����+[��qU��-�����yjJ���E]�=�-]i�ؤW�zj��YR���s�����������u���]g�}���o�5�}�u����Ouv���GKc�(r�<��7{��Gi�H!#$Pn������j^{�k�oV���҇ɧ�+2��s�2`}h�G\�6��ٶ֠OW\�2��½��.����l��%��E�z�F�j���׽m��/o`�O/r7n�w�J�{����z�{޻��s��(w�XI����{��v׺c������c�mp���v������D���i���I�L# �& �� #$@bz�OQ� M��&��2�zj#$S�LS&�L@mM��� ��LM0#%�MOd�)�yO@����=M��F ��i��ML�&�4��G����jyO4�A��#$&���� @ � � �d#�j�M53S$z��ڀ4 544�Oh�b��M3MMi6��2dɣ@4�����W��h�#%#%?"+�QU����DQ-JP$��P���n^�Z|�W°���m��>Vª���f�N#$�f���kz|?�?�_WʂbB�BI�u�������L���}�sowh|*W���)�^ݦ����W�{���Ȭ!���DGh@#$�H�E܊�]�Ԩ�<&P� n�U��.^J�Q�9ȱr�EDA�h( ��b�iVY�#%� ��(��&"%�JbX&*����(���"j%�&����&ah�fbh���"bB#%��!ZIb�*(���b�����h�#%$��%��%!�Z�H$�B@�H"(���B�� ��I��*� ��e�a��"Ib��f�������%"����#%��#%�����`"bf`����#%�h�h(���*� �)Yh�&#%�`"*J(f%%������**����jRh�� �"�����(����))���*�b ���d�JJJF�#%(�"�&"��f�������&JH(�*���(f�����%�Z*�( ��(���&�J���a(#%�b�`�Jh����"�#% (��*�(���()�*i��*����"#%����JBI�����$���&hh����& ���%�(��������#%�b(����*�`bJ���")��b��f�* "h)�)�fb���X�(!���I�HfV#%(j )**J����#%��*�f�B����#%"*)�������"��*�J������h%�&�f��*����D���"bX�������) ��()������i"����(&bhH�(���F�Jh�(�R��� ���!�*`�j�h#%i��i���A��( �"�J�(j�B����hh"#%������ "�$������d��#%���)�) ��*$((��j��������#%�#%�$jbH�b�#%J"��*��#%������b�b�"����j"��Jj���4CE  ADD��5)A@,�!D@C4�BP %RRTB�L�$�,T�PAAS50TQB�D��R�@�D�UQSP�TEQM$+ԑE�11KIDIA�Q$�HJ�$0E4R4�� ��0�4�� P�#$P�P @E@�SP%(��E% MA�MD�AMLT���,H�L"!$Ċ�#%�T���UQL �CC��C���I1�D�$�M$@�ĕ, �S $M$�5EDMESPADC�225A$�SDI�!2R�T4UUELEUAQ@P���#$KU0A-!CT� �$�0T�HDAL�4� �R)D�E2�K44�SPCE)TTMU#$�KDKIHP�L���HU4��!ABQ@5@RTT �QPTR�D�E)E ABT�BP�EL��%0PL�T�QDL��JPPP�%DT�EAAAP�RLJHDM�A$�!TP� A1CET�$HDM3$�L5C4P�S4�K��!KT�IDICM% ʑDEKS15PL�54�KSASM#$S4�Q43� J�"PA%I�4��Q10�RT12D)JMITK,�Q@�$DL�K!B�44�AQ-4��MPKELM% 4�P�C P�0A@HRP��R4���R�S0����%$CE �LDU�J!)2RD�% �%@��TIT#$@TCADQCU�H�UHD$L��#R��1#$�DE@4�EQ%! �E)�35DK�ADSEB�P�D��1K��#�D�PU,@)@J�āI,E2��JE��U#%ĠMS)U+��A0UEU E$�#$PČU@DA40K%!T5ID�U1TSL�4�TP�-,��%KDSAI1��QLDA UEAT�EAT,��LDDTH��$��)E�4HU A%TUEI DK#$RRS@A5ySCUQQERLD�_�]kF0�<�&_�Ç���۪f��k����q!A>Q�4-��p@>�����<�Sѿ�w��#$7�)'�#$x�~|�����K`�M7��?��1��*~���;n ��*`�b��L/��O;���@��-�M8`��4U J)"� ���(�|3p�?�ʰ6NI2����gkK�l D�P��Z����!f=����t)v�N��^8�3P��G+��F���Pb*�PJm]��#$rO�p���[����7���mg���1�0{����k��1��1��*]���plj���u�Z��j3L^�����b:�(Ӊ"�h��#$�"L6xY+.gj�٥NUF�_p�e���#%��6(��������5����=��ɷ� M$E�I�2r#%�'A�-{R�QCvJOk#l;�dO���h����ާ ���ݾ>#�:;��T��`ҥ'����1�,����ԇl���t�[Z�i+���%�C˟�����2�h��0��� 9g���Ɂ4��`IJʅ�(2r�A�È#%|A�S�J��\]�X��I J�!���x�GVf�ޥ[,���7�g���ԇ���*��U�#%��G-�����`�����m���g]��iA�}7PV=P�"��a��QA����Ak�� �pδ\�&�rB��+&��b���Yݭ�z�����Yc���rx������UM*,4�VҢ�����J謤�a4�s�#$�xڻY�!��:0s�(�w�W�f�;��z��6�\����F�q��R+J�F��;�g{���VsG���r��i�h���p�):��_�OOwn4P����_�w�ހ�����M�X�vQ ���D@�u�N��I�+���{R �(��T���
  124. #<==