Uvedale/CGMinerTuner — pull request #1 by vassilevsky (2014-01-02 23:49:10+00:00)
Title: Simplify / fix top result selection

Dear Dale,

Thank you very much for this awesome script. It makes the process of tuning the clocks really fun.

However, I have found that the `report` method gives incorrect results:

```
03-01-2014 02:02:54: Core: 1000, Mem: 1440, MH: 0.34975, Ratio: 0.69, Temp: 74.0

03-01-2014 02:03:27: Core: 1000, Mem: 1450, MH: 0.3503, Ratio: 0.69, Temp: 74.0

03-01-2014 02:04:03: Core: 1010, Mem: 1440, MH: 0.3525, Ratio: 0.7, Temp: 74.0

03-01-2014 02:04:36: Core: 1010, Mem: 1450, MH: 0.3529, Ratio: 0.7, Temp: 74.0

03-01-2014 02:05:12: Core: 1020, Mem: 1440, MH: 0.35565, Ratio: 0.71, Temp: 74.0

03-01-2014 02:05:45: Core: 1020, Mem: 1450, MH: 0.35595, Ratio: 0.7, Temp: 74.0

03-01-2014 02:06:21: Core: 1030, Mem: 1440, MH: 0.3587, Ratio: 0.72, Temp: 74.0

03-01-2014 02:06:54: Core: 1030, Mem: 1450, MH: 0.3589, Ratio: 0.71, Temp: 74.0

03-01-2014 02:07:30: Core: 1040, Mem: 1440, MH: 0.35975, Ratio: 0.72, Temp: 74.0

03-01-2014 02:08:03: Core: 1040, Mem: 1450, MH: 0.3614, Ratio: 0.72, Temp: 74.0

03-01-2014 02:08:40: Core: 1050, Mem: 1440, MH: 0.3622, Ratio: 0.73, Temp: 74.0

03-01-2014 02:09:13: Core: 1050, Mem: 1450, MH: 0.36285, Ratio: 0.72, Temp: 74.0

-- Report on 52 results --

1: MH: 0.36285, Core: 1050, Mem: 1450, Core/Mem Ratio: 0.72, Temp: 74.0
2: MH: 0.2847, Core: 800, Mem: 1450, Core/Mem Ratio: 0.55, Temp: 71.0
3: MH: 0.28785, Core: 810, Mem: 1440, Core/Mem Ratio: 0.56, Temp: 73.0
4: MH: 0.28805, Core: 810, Mem: 1450, Core/Mem Ratio: 0.56, Temp: 74.0
5: MH: 0.29145, Core: 820, Mem: 1440, Core/Mem Ratio: 0.57, Temp: 74.0
```

I inspected the algorithm of filling the `top` array in the `report` method and found it a bit cumbersome. I then took the liberty of rewriting it with a sort + slice algorithm.

It gave the correct results:

```
-- Starting tuner --
Core Range: 1045 - 1050 in steps of 5, Mem Range: 1240 - 1260 in steps of 5
Estimated time to completion: 0 hours and 3 minutes

03-01-2014 03:31:27: Core: 1045, Mem: 1240, MH: 0.36595, Ratio: 0.84, Temp: 73.0

03-01-2014 03:32:00: Core: 1045, Mem: 1245, MH: 0.36575, Ratio: 0.84, Temp: 73.0

03-01-2014 03:32:33: Core: 1045, Mem: 1250, MH: 0.3654, Ratio: 0.84, Temp: 73.0

03-01-2014 03:33:06: Core: 1045, Mem: 1255, MH: 0.3571, Ratio: 0.83, Temp: 73.0

03-01-2014 03:33:39: Core: 1045, Mem: 1260, MH: 0.35695, Ratio: 0.83, Temp: 73.0

03-01-2014 03:34:15: Core: 1050, Mem: 1240, MH: 0.3669, Ratio: 0.85, Temp: 73.0

03-01-2014 03:34:48: Core: 1050, Mem: 1245, MH: 0.3673, Ratio: 0.84, Temp: 73.0

03-01-2014 03:35:21: Core: 1050, Mem: 1250, MH: 0.3685, Ratio: 0.84, Temp: 73.0

03-01-2014 03:35:54: Core: 1050, Mem: 1255, MH: 0.3586, Ratio: 0.84, Temp: 73.0

03-01-2014 03:36:28: Core: 1050, Mem: 1260, MH: 0.35825, Ratio: 0.83, Temp: 73.0

-- Report on 10 results --

1: MH: 0.3685, Core: 1050, Mem: 1250, Core/Mem Ratio: 0.84, Temp: 73.0
2: MH: 0.3673, Core: 1050, Mem: 1245, Core/Mem Ratio: 0.84, Temp: 73.0
3: MH: 0.3669, Core: 1050, Mem: 1240, Core/Mem Ratio: 0.85, Temp: 73.0
4: MH: 0.36595, Core: 1045, Mem: 1240, Core/Mem Ratio: 0.84, Temp: 73.0
5: MH: 0.36575, Core: 1045, Mem: 1245, Core/Mem Ratio: 0.84, Temp: 73.0
```

I hope that you like my small improvement.

Thank you.