Commit Graph

29 Commits

Author SHA1 Message Date
mmorel-35 1e6b445a8a gofumpt 2021-12-22 21:54:41 +00:00
shirou bde422a2ff [cpu][mac] doesn't return error when cpu.frequency 2021-12-04 04:23:33 +00:00
shirou 0969c9436b delete v2 directory, move v3 to top #1078 2021-11-30 23:47:59 +00:00
Tobias Klauser ee12f66e4d cpu, v3/cpu: use sysconf package instead of exec'ing getconf
Currently, ClocksPerSec is determined by exec'ing getconf in func init,
i.e. on startup of every program importing the package. getconf might
not be present on some systems or is not executable by the current user.
To avoid this hard to control dependency, use the
github.com/tklauser/go-sysconf package which implements sysconf(3)
entirely in Go without cgo. The package is supported on all platforms
currently supported by the cpu and v3/cpu package of gopsutil.
2021-02-19 12:20:10 +01:00
renaynay d4985c9690
added check for CLK_TCK 2020-05-12 13:59:26 +02:00
Minje Park caebe5dbe4 returning 0 and error if SysctlUint32 raises an error 2019-03-21 23:52:34 +09:00
Minje Park ca1fcad2aa retrieve a cpu count depends on an boolean argument 2019-03-17 23:18:29 +09:00
Lomanic c0ca431bf1 [cpu][linux] Add support for logical arg in Counts #640 #628 2019-03-03 14:44:21 +01:00
Lomanic 2ec35609d2 [cpu][darwin] Remove calls to sysctl binary in cpu/cpu_darwin.go #639
Empirical benchmark (calling to cpu.Info):

Lomanics-iMac:~ lomanic$ time ./cpu_info
info 0: {"cpu":0,"vendorId":"GenuineIntel","family":"6","model":"30","stepping":5,"physicalId":"","coreId":"","cores":2,"modelName":"Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz","mhz":2590,"cacheSize":256,"flags":["syscall","xd","em64t","lahf","lzcnt","prefetchw","rdtscp","tsci","fpu","vme","de","pse","tsc","msr","pae","mce","cx8","apic","sep","mtrr","pge","mca","cmov","pat","pse36","clfsh","mmx","fxsr","sse","sse2","htt","sse3","ssse3","cx16","sse4.1","sse4.2","popcnt","vmm"],"microcode":""}

real    0m0.049s
user    0m0.023s
sys     0m0.041s
Lomanics-iMac:~ lomanic$ time ./cpu_info.fixed
info 0: {"cpu":0,"vendorId":"GenuineIntel","family":"6","model":"30","stepping":5,"physicalId":"","coreId":"","cores":2,"modelName":"Intel(R) Core(TM) i5-6440HQ CPU @ 2.60GHz","mhz":2590,"cacheSize":256,"flags":["fpu","vme","de","pse","tsc","msr","pae","mce","cx8","apic","sep","mtrr","pge","mca","cmov","pat","pse36","clfsh","mmx","fxsr","sse","sse2","htt","sse3","ssse3","cx16","sse4.1","sse4.2","popcnt","vmm","syscall","xd","em64t","lahf","lzcnt","prefetchw","rdtscp","tsci"],"microcode":""}

real    0m0.010s
user    0m0.004s
sys     0m0.006s
2019-03-02 23:22:53 +01:00
shirou 145dca90f7 change to use CommandContext. 2018-03-31 21:35:53 +09:00
shirou 4c73494c78 Add WithContext functions. 2017-12-31 15:25:49 +09:00
K.C. Wong 123a6c9b0d Addressing frequency unit discrepancies
* for Darwin, it is a minor tweak for readability: the value
  returned is in Hz, so using a variable named 'hz' makes more
  sense than 'mhz'
* for Linux, the unit is in kHz so we need to divide the value
  from `cpuinfo_max_freq` by 10^3 to get MHz (see
  cpu-freq/user-guide.txt of the kernel documentation)
2016-08-23 17:21:30 -07:00
Shirou WAKAYAMA 57f6aebc7e add Timeout to invoke command and use common.Invoke refs: #201 2016-05-20 17:59:41 +09:00
Shirou WAKAYAMA d21ed2b40d search path via exec.LookPath before actual invoke. 2016-04-01 22:13:05 +09:00
Shirou WAKAYAMA ea152ea901 [BREAKING CHANGE] rename functions to pass golint. ex) net.NetIOCounters -> net.IOCounters 2016-03-22 23:09:12 +09:00
Shirou WAKAYAMA a95dde9672 cpu[darwin]: separetes cpu_darwin to cgo and nocgo to get CPUTimes. 2015-10-10 22:13:38 +09:00
Shirou WAKAYAMA 47f6760cf3 cpu[darwin]: use CGO to get CPUTimes. This is breaking. see #66. 2015-08-28 17:01:43 +09:00
Shirou WAKAYAMA 0d7ff2eb40 cpu[darwin]: convert cpu frequency to Mhz. 2015-08-27 15:50:35 +09:00
Chris Bednarski d5fa4f880f Read Darwin CPU frequency from sysctl hw.cpufrequency 2015-08-26 11:45:09 -07:00
Shirou WAKAYAMA cbe10d6761 cpu[darwin]: move helper path to under the HOME dir. 2015-07-29 22:25:42 +09:00
Shirou WAKAYAMA c195d77ce3 cpu[darwin]: enable cpu helper only the environemnetal variable set. 2015-07-25 12:49:02 +09:00
Shirou WAKAYAMA 755d3a4119 cpu[darwin]: change default tick to 100. 2015-07-24 15:01:22 +09:00
Shirou WAKAYAMA 12843632ca cpu[darwin]: experimental implemtation to get CPU times on darwin. 2015-07-24 14:49:35 +09:00
WAKAYAMA shirou 4bc631921f cpu: fix command output trim problem. 2015-07-17 21:52:43 +09:00
Shirou WAKAYAMA 8c17a750c6 get CLOCK TICK by using getconf. 2015-07-17 21:46:26 +09:00
WAKAYAMA shirou b8dc51929a forget to change float32 to float64 2015-02-15 20:48:29 +09:00
Shirou WAKAYAMA 4b5bf22b88 change CPUTimes type from float32 to float64 to resolve precision issue. 2015-02-13 22:45:12 +09:00
Shirou WAKAYAMA 13cd195a7e change package name. 2014-12-30 22:09:05 +09:00
Shirou WAKAYAMA a4671fcc2a move subdirectories. refer to issue #24 2014-11-27 10:18:15 +09:00