Skip to content

Instantly share code, notes, and snippets.

@mageddo
Created December 22, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mageddo/e7fb867f965ffd97a56f78be6e61618f to your computer and use it in GitHub Desktop.
Save mageddo/e7fb867f965ffd97a56f78be6e61618f to your computer and use it in GitHub Desktop.
Get TDP cpu information
import java.util.Scanner;
public class HexToDecimal {
public static void main(String[] args) {
System.out.println(Integer.parseInt(new Scanner(System.in).nextLine(), 16));
}
}
import java.util.Locale;
import java.util.Objects;
import java.util.Scanner;
public class MsrWatts {
public static void main(String[] args) {
Locale.setDefault(Locale.ENGLISH);
final double power = 0.125;
final int msr = Integer.parseInt(new Scanner(System.in).nextLine(), 16);
if(args.length == 0 || Objects.equals(args[0], "-d")){
System.out.printf("%.2f%n", msr * power);
} else if(Objects.equals(args[0], "-h")) {
System.out.printf("%.2f%n", msr / power);
} else {
System.out.println("unknown option");
}
}
}
#!/bin/bash
echo "max tdp"
rdmsr -f 14:0 0x610 | java msr2watts.java
echo "turbo boost tdp"
rdmsr -f 46:32 0x610 | java msr2watts.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment