func BenchmarkGetProcess(b *testing.B) {
	pids, err := Pids()
	if err != nil {
		b.Fatal(err)
	}
	nPids := len(pids)
	procs := make(ProcsMap, nPids)

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		pid := pids[i%nPids]

		var cmdline string
		var env common.MapStr
		if p := procs[pid]; p != nil {
			cmdline = p.CmdLine
			env = p.Env
		}

		process, err := newProcess(pid, cmdline, env)
		if err != nil {
			continue
		}
		err = process.getDetails(nil)
		assert.NoError(b, err)

		procs[pid] = process
	}
}
// BenchmarkGetProcess runs a benchmark of the GetProcess method with caching
// of the command line and environment variables.
BenchmarkGetProcess runs a benchmark of the GetProcess method with caching
of the command line and environment variables.
// BenchmarkGetProcess runs a benchmark of the GetProcess method with caching // of the command line and environment variables .
func BenchmarkGetProcess(b *testing.B) {
	pids, err := Pids()
	if err != nil {
		b.Fatal(err)
	}
	nPids := len(pids)
	procs := make(ProcsMap, nPids)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		pid := pids[i%nPids]
		var cmdline string
		var env common.MapStr
		if p := procs[pid]; p != nil {
			cmdline = p.CmdLine
			env = p.Env
		}
		process, err := newProcess(pid, cmdline, env)
		if err != nil {
			continue
		}
		err = process.getDetails(nil)
		assert.NoError(b, err)
		procs[pid] = process
	}
}
func BenchmarkGetProcess ( b * testing . B ) { pids , err := Pids ( ) if err != nil { b . Fatal ( err ) } nPids := len ( pids ) procs := make ( ProcsMap , nPids ) b . ResetTimer ( ) for i := 0 ; i < b . N ; i ++ { pid := pids [ i % nPids ] var cmdline string var env common . MapStr if p := procs [ pid ] ; p != nil { cmdline = p . CmdLine env = p . Env } process , err := newProcess ( pid , cmdline , env ) if err != nil { continue } err = process . getDetails ( nil ) assert . NoError ( b , err ) procs [ pid ] = process } }
BenchmarkGetProcess runs a benchmark of the GetProcess method with caching
of the command line and environment variables.
BenchmarkGetProcess runs a benchmark of the GetProcess method with caching of the command line and environment variables .