Ubuntu Pastebin

Paste from smoser at Tue, 16 Aug 2016 19:54:04 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
== [strace python load-python] python /tmp/my.py -1 does_not_matter ==

real	0m0.041s
user	0m0.016s
sys	0m0.024s
stats or opens: 360
== [strace python import-pkgresources] python /tmp/my.py 0 does_not_matter ==

real	0m0.370s
user	0m0.168s
sys	0m0.224s
stats or opens: 2422
== [strace python one iter_entry_points] python /tmp/my.py 1 does_not_matter ==

real	0m0.578s
user	0m0.388s
sys	0m0.216s
stats or opens: 2561
== [strace python 10 iter_entry_points] python /tmp/my.py 10 does_not_matter ==

real	0m0.566s
user	0m0.412s
sys	0m0.180s
stats or opens: 2561
== [strace python3 load-python] python3 /tmp/my.py -1 does_not_matter ==

real	0m0.045s
user	0m0.028s
sys	0m0.016s
stats or opens: 211
== [strace python3 import-pkgresources] python3 /tmp/my.py 0 does_not_matter ==

real	0m0.326s
user	0m0.232s
sys	0m0.104s
stats or opens: 2119
== [strace python3 one iter_entry_points] python3 /tmp/my.py 1 does_not_matter ==

real	0m0.478s
user	0m0.364s
sys	0m0.128s
stats or opens: 2250
== [strace python3 10 iter_entry_points] python3 /tmp/my.py 10 does_not_matter ==

real	0m0.427s
user	0m0.312s
sys	0m0.124s
stats or opens: 2250
== [no-strace python load-python] python /tmp/my.py -1 does_not_matter ==

real	0m0.010s
user	0m0.008s
sys	0m0.000s
== [no-strace python import-pkgresources] python /tmp/my.py 0 does_not_matter ==

real	0m0.130s
user	0m0.112s
sys	0m0.016s
== [no-strace python one iter_entry_points] python /tmp/my.py 1 does_not_matter ==

real	0m0.320s
user	0m0.316s
sys	0m0.000s
== [no-strace python 10 iter_entry_points] python /tmp/my.py 10 does_not_matter ==

real	0m0.316s
user	0m0.296s
sys	0m0.016s
== [no-strace python3 load-python] python3 /tmp/my.py -1 does_not_matter ==

real	0m0.026s
user	0m0.020s
sys	0m0.004s
== [no-strace python3 import-pkgresources] python3 /tmp/my.py 0 does_not_matter ==

real	0m0.191s
user	0m0.184s
sys	0m0.004s
== [no-strace python3 one iter_entry_points] python3 /tmp/my.py 1 does_not_matter ==

real	0m0.261s
user	0m0.244s
sys	0m0.016s
== [no-strace python3 10 iter_entry_points] python3 /tmp/my.py 10 does_not_matter ==

real	0m0.276s
user	0m0.256s
sys	0m0.020s
=== /tmp/my.py ====
#!/usr/bin/python

def iter_entry_points(namespace, loader=None, name=None):
    for e in pkg_resources.iter_entry_points(namespace, name=name):
        if loader is None:
            thing = e.load()
        else:
            thing = loader(e)
        if thing is not None:
            yield (e.name, thing)

if __name__ == '__main__':
    import sys
    numloops = int(sys.argv[1])
    args = sys.argv[2:]
    if numloops == -1:
        sys.exit(0)
    import pkg_resources
    if numloops == 0:
        sys.exit(0)
    for i in range(0, numloops):
        for entry in iter_entry_points(*args):
            print("entry: %s" % entry)
=== /tmp/go.sh ===
#!/bin/bash

prog="/tmp/my.py"
arg="does_not_matter"
for s in strace no-strace; do
    if [ "$s" = "strace" ]; then
        strace="$s -o out"
    else
        strace=""
    fi
    for python in python python3; do 
        for num in -1 0 1 10; do
           case "$num" in
               -1) desc="load-python";;
               0) desc="import-pkgresources";;
               1) desc="one iter_entry_points";;
               *) desc="$num iter_entry_points";;
           esac
           echo == [$s $python $desc] $python $prog $num $arg ==
           time $strace $python "$prog" $num $arg
           if [ "$s" = "strace" ]; then
               echo "stats or opens: "$(egrep -c "^(stat|open)" out)
           fi
        done
    done
done

echo === /tmp/my.py ====
cat /tmp/my.py

echo === $0 ===
cat $0
Download as text