-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// Lscpu.swift | ||
// | ||
// | ||
// Created by Ondrej Rafaj on 10/07/2019. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct Lscpu: Command { | ||
|
||
public static var command: String { | ||
return "lscpu" | ||
} | ||
|
||
public static func parse(_ string: String) -> Lscpu { | ||
let vendor = string.line(with: "Vendor ID:")?.dropTillFirstColon() ?? "n/a" | ||
let model = string.line(with: "Model name:")?.dropTillFirstColon() ?? "n/a" | ||
let hypervisor = string.line(with: "Hypervisor vendor:")?.dropTillFirstColon() ?? "n/a" | ||
let sockets = string.line(with: "Socket(s):")?.intOnly() ?? 0 | ||
let cores = string.line(with: "CPU(s):")?.intOnly() ?? 0 | ||
let clock = string.line(with: "CPU MHz:")?.doubleOnly() ?? 0.0 | ||
|
||
return Lscpu( | ||
vendor: vendor, | ||
model: model, | ||
hypervisor: hypervisor, | ||
sockets: sockets, | ||
cores: cores, | ||
clock: (clock * 1_000_000) | ||
) | ||
} | ||
|
||
public let vendor: String | ||
public let model: String | ||
public let hypervisor: String? | ||
public let sockets: Int? | ||
public let cores: Int | ||
public let clock: Double | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters