0.1.140
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| [metadata] | [metadata] | ||||||
| # replace with your username: | # replace with your username: | ||||||
| name = guan | name = guan | ||||||
| version = 0.1.139 | version = 0.1.140 | ||||||
| author = guanjihuan | author = guanjihuan | ||||||
| author_email = guanjihuan@163.com | author_email = guanjihuan@163.com | ||||||
| description = An open source python package | description = An open source python package | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| Metadata-Version: 2.1 | Metadata-Version: 2.2 | ||||||
| Name: guan | Name: guan | ||||||
| Version: 0.1.139 | Version: 0.1.140 | ||||||
| Summary: An open source python package | Summary: An open source python package | ||||||
| Home-page: https://py.guanjihuan.com | Home-page: https://py.guanjihuan.com | ||||||
| Author: guanjihuan | Author: guanjihuan | ||||||
|   | |||||||
| @@ -744,8 +744,8 @@ def get_cpu_averaged_usage_for_non_zero_cores(interval=1): | |||||||
|     averaged_cpu_usage = sum(cpu_usage_array_per_core_new)/len(cpu_usage_array_per_core_new) |     averaged_cpu_usage = sum(cpu_usage_array_per_core_new)/len(cpu_usage_array_per_core_new) | ||||||
|     return averaged_cpu_usage |     return averaged_cpu_usage | ||||||
|  |  | ||||||
| # 在一定数量周期内得到CPU的使用率信息。默认为10秒钟收集一次,(interval+sleep_interval)*times 为收集的时间范围,范围默认为60秒,即1分钟后返回列表,总共得到6组数据。其中,数字第一列和第二列分别是平均值和最大值。 | # 在一定数量周期内得到CPU的使用率信息。默认为1秒钟收集一次,(interval+sleep_interval)*times 为收集的时间范围,范围默认为60秒,即1分钟后返回列表,总共得到60组数据。其中,数字第一列和第二列分别是平均值和最大值。 | ||||||
| def get_cpu_information_for_times(interval=1, sleep_interval=9, times=6): | def get_cpu_information_for_times(interval=1, sleep_interval=0, times=60): | ||||||
|     import guan |     import guan | ||||||
|     import time |     import time | ||||||
|     cpu_information_array = [] |     cpu_information_array = [] | ||||||
| @@ -764,8 +764,8 @@ def get_cpu_information_for_times(interval=1, sleep_interval=9, times=6): | |||||||
|         time.sleep(sleep_interval) |         time.sleep(sleep_interval) | ||||||
|     return cpu_information_array |     return cpu_information_array | ||||||
|  |  | ||||||
| # 将得到的CPU的使用率信息写入文件。默认为半分钟收集一次,(interval+sleep_interval)*times 为收集的时间范围,范围默认为60分钟,即1小时写入文件一次,总共得到120组数据。其中,数字第一列和第二列分别是平均值和最大值。 | # 将得到的CPU的使用率信息写入文件。默认为1分钟收集一次,(interval+sleep_interval)*times 为收集的时间范围,范围默认为60分钟,即1小时写入文件一次,总共得到60组数据。其中,数字第一列和第二列分别是平均值和最大值。 | ||||||
| def write_cpu_information_to_file(filename='./cpu_usage', interval=1, sleep_interval=29, times=120): | def write_cpu_information_to_file(filename='./cpu_usage', interval=1, sleep_interval=59, times=60): | ||||||
|     import guan |     import guan | ||||||
|     guan.make_file(filename+'.txt') |     guan.make_file(filename+'.txt') | ||||||
|     while True: |     while True: | ||||||
| @@ -782,8 +782,8 @@ def write_cpu_information_to_file(filename='./cpu_usage', interval=1, sleep_inte | |||||||
|             f.write('\n') |             f.write('\n') | ||||||
|         f.close() |         f.close() | ||||||
|  |  | ||||||
| # 画CPU的使用率图。默认为画最近的120个数据,以及不画CPU核心的最大使用率。 | # 画CPU的使用率图。默认为画最近的60个数据,以及不画CPU核心的最大使用率。 | ||||||
| def plot_cpu_information(filename='./cpu_usage', recent_num=120, max_cpu=0): | def plot_cpu_information(filename='./cpu_usage', recent_num=60, max_cpu=0): | ||||||
|     import guan |     import guan | ||||||
|     from datetime import datetime |     from datetime import datetime | ||||||
|     with open(filename+".txt", "r") as file: |     with open(filename+".txt", "r") as file: | ||||||
| @@ -816,7 +816,7 @@ def plot_cpu_information(filename='./cpu_usage', recent_num=120, max_cpu=0): | |||||||
|     plt.show() |     plt.show() | ||||||
|  |  | ||||||
| # 画详细的CPU的使用率图,分CPU核心画图。 | # 画详细的CPU的使用率图,分CPU核心画图。 | ||||||
| def plot_detailed_cpu_information(filename='./cpu_usage', recent_num=120): | def plot_detailed_cpu_information(filename='./cpu_usage', recent_num=60): | ||||||
|     import guan |     import guan | ||||||
|     from datetime import datetime |     from datetime import datetime | ||||||
|     with open(filename+".txt", "r") as file: |     with open(filename+".txt", "r") as file: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user