HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/thread-self/root/usr/share/doc/m2crypto-0.21.1/demo/perf/memio.py
#!/usr/bin/python2.0

"""A comparison of Python's cStringIO and M2Crypto's MemoryBuffer,
the outcome of which is that MemoryBuffer suffers from doing too much
in Python. 

Two way to optimise MemoryBuffer:
1. Create MemoryBufferIn and MemoryBufferOut a la StringI and StringO.
2. Have MemoryBuffer do all internal work with cStringIO. ;-)
"""

from cStringIO import StringIO
from M2Crypto.BIO import MemoryBuffer
from M2Crypto import m2
import profile

txt = 'Python, Smalltalk, Haskell, Scheme, Lisp, Self, Erlang, ML, ...'

def stringi(iter, txt=txt):
    buf = StringIO()
    for i in range(iter):
        buf.write(txt)
    out = buf.getvalue()

def membufi(iter, txt=txt):
    buf = MemoryBuffer()
    for i in range(iter):
        buf.write(txt)
    out = buf.getvalue()

def membuf2i(iter, txt=txt):
    buf = MemoryBuffer()
    buf.write(txt * iter)
    out = buf.getvalue()

def cmembufi(iter, txt=txt):
    buf = m2.bio_new(m2.bio_s_mem())
    for i in range(iter):
        m2.bio_write(buf, txt)
    m2.bio_set_mem_eof_return(buf, 0)
    out = m2.bio_read(buf, m2.bio_ctrl_pending(buf))

if __name__ == '__main__':
    profile.run('stringi(10000)')
    profile.run('cmembufi(10000)')
    profile.run('membufi(10000)')
    profile.run('membuf2i(10000)')