2

I'm trying to get the real max cpu cores speed.

This code works just for the four first cores of my nexus 5x, but it fails for the last two cores:

        for (int i = 0; i < cpuCoresNumber; i++) {
            try {
                BufferedReader freqBufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/sys/devices/system/cpu/cpu" + i + "/cpufreq/scaling_max_freq"))));
                int freq = Integer.valueOf(freqBufferedReader.readLine()).intValue() / 1000;
                freqBufferedReader.close();
                coreMaxFreqArray[i] = freq;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

For the first 4 i get real values, for the last 2, first i get real values, but sometimes i get lower values like for example 600, 300, 0.... and the real value of that two last cores is 1800mhz.

NullPointerException
  • 36,107
  • 79
  • 222
  • 382
  • 1
    Some quick googling gave me this: _"SoC throttling is also another major issue that significantly slows down the Nexus 5x. "Snapdragon 808 can only keep its two A57 cores at their peak frequency for two minutes before throttling both down to 633MHz and putting the A53s up to their peak 1.44GHz," Anandtech says in its Nexus 5X system performance review. "After 12 minutes the A57s are just shut off entirely, and you're left with a cluster of 4 A53 cores at 1.44GHz.""_ – Michael Oct 05 '16 at 11:30
  • yes but i can see the max speed of the cores in some apps of google play which are checking the max speed of that cores, so i'm sure it is possible to check it somewhere – NullPointerException Oct 05 '16 at 12:58
  • Have you tried obtaining the result of `"cat /sys/devices/system/cpu/cpu" + i + "/cpufreq/scaling_available_frequencies"` and picking the largest number? – Michael Oct 05 '16 at 13:51
  • @Michael tryed it but exactly the same result. That file is not available when the cpu returns 0 values. and has less available values when the other file has less available values... – NullPointerException Oct 05 '16 at 14:42
  • Did you ever find a way to do this reliably? I'm having the same issue with only getting the max frequency of the first 4 slower cores on a Snapdragon 835 device. – Bryan C Sep 03 '18 at 15:38

1 Answers1

1

Try some of this, i executed commands to get the max frequency of each core.

    private String exCommand(String comando) throws IOException {
    try {
        Process process = Runtime.getRuntime().exec(comando);
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        int read;
        char[] buffer = new char[4096];
        StringBuilder output = new StringBuilder();
        while ((read = reader.read(buffer)) > 0) {
            output.append(buffer, 0, read);
        }
        reader.close();
        process.waitFor();
        return output.toString();
    } catch (IOException | InterruptedException e) {
        throw new RuntimeException(e);
    }
}

And writed this code on my main method to get each core speed

        for (int i = 0; i <= cores; i++) {
        speed = exCommand("cat /sys/devices/system/cpu/cpu"+i+"/cpufreq/cpuinfo_max_freq");
        vel = Double.parseDouble(speed);
        vel = vel /1000000;
        System.out.println(vel);
    }

Hope it helps

Ignacio Olcina
  • 104
  • 1
  • 7