4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ElixirでCPUの周波数を取得をする

Last updated at Posted at 2024-07-20

前提

OS Ubuntu 22.04
実行環境 Livebook

ソース

File.read!("/proc/cpuinfo")
|> String.split("\n")
|> Enum.filter(&String.match?(&1, ~r/cpu MHz/))
|> Enum.each(&IO.puts(&1))

/proc/cpuinfoからCPU情報を取得
・1行毎に分割
cpu MHzの行でフィルター
・表示

結果

image.png

cpu MHz		: 985.976
cpu MHz		: 1096.658
cpu MHz		: 1091.907
cpu MHz		: 800.000
cpu MHz		: 1074.477
cpu MHz		: 800.000
cpu MHz		: 1098.162
cpu MHz		: 1090.260
cpu MHz		: 1100.000
cpu MHz		: 800.000
cpu MHz		: 1084.603
cpu MHz		: 800.000
cpu MHz		: 1099.995
cpu MHz		: 1100.007
cpu MHz		: 1087.751
cpu MHz		: 1092.324
cpu MHz		: 800.019
cpu MHz		: 800.018
cpu MHz		: 799.974
cpu MHz		: 800.001
cpu MHz		: 800.013
cpu MHz		: 800.172
cpu MHz		: 800.006
cpu MHz		: 800.011
cpu MHz		: 800.145
cpu MHz		: 800.000
cpu MHz		: 800.112
cpu MHz		: 800.000
cpu MHz		: 800.098
cpu MHz		: 800.000
cpu MHz		: 800.000
cpu MHz		: 800.000
4
2
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?