如何获得点击数:
(pprof) top
Total: 2525 samples
298 11.8% 11.8% 345 13.7% runtime.mapaccess1_fast64
268 10.6% 22.4% 2124 84.1% main.FindLoops
Run Code Online (Sandbox Code Playgroud)
不,持续时间如:
(pprof) top
2220ms of 3080ms total (72.08%)
Dropped 72 nodes (cum <= 15.40ms)
Showing top 10 nodes out of 111 (cum >= 60ms)
flat flat% sum% cum cum%
1340ms 43.51% 43.51% 1410ms 45.78% runtime.cgocall_errno
Run Code Online (Sandbox Code Playgroud)
环境:我使用golang1.4,添加以下代码.
defer pprof.StopCPUProfile()
f, err := os.Create("innercpu.pprof")
if err != nil {
fmt.Println("Error: ", err)
}
pprof.StartCPUProfile(f)
Run Code Online (Sandbox Code Playgroud) ndarray如何使用简单的函数,如x**2?我收到此错误:
arr = array([3,4,5])
f = lambda x: x**2
print f(arr) # works, but how?
print f(3) # works
print f([3,4,5]) # will not work
#TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'
print f((3,4,5)) # will not work
#TypeError: unsupported operand type(s) for ** or pow(): 'tuple' and 'int'
>>>f(arr)
#[ 9 16 25]
>>>f(3)
#9
Run Code Online (Sandbox Code Playgroud)
最后...
class Info(object):
def __init__(self,x):
self.a = x<
def __pow__(self,x):
for i in xrange(len(self.a)):
self.a[i]**=x
return self
a = Info([3,4]) …Run Code Online (Sandbox Code Playgroud)