From 5fef3a7b1dec5c6a83ed6331b39f8770f584d167 Mon Sep 17 00:00:00 2001 From: integralfx Date: Sat, 23 Mar 2019 11:47:50 +1100 Subject: [PATCH] Bug fixes --- MemTestHelper/Form1.cs | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/MemTestHelper/Form1.cs b/MemTestHelper/Form1.cs index 8dd7b49..af5ac68 100644 --- a/MemTestHelper/Form1.cs +++ b/MemTestHelper/Form1.cs @@ -10,6 +10,7 @@ using System.IO; using System.Linq; using System.Management; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; @@ -80,31 +81,10 @@ public Form1() if (total_coverage == 0) return; + // round up to next multiple of 100 + int cov = ((int)(total_coverage / 100) + 1) * 100; double diff = elapsed.TotalMilliseconds, - est = 0; - int cov = 0; - // use user input coverage % - if (chk_stop_at.Checked) - { - cov = Convert.ToInt32(txt_stop_at.Text); - - if (chk_stop_at_total.Checked) - est = (diff / total_coverage * cov) - diff; - else - { - // calculate average coverage and use that to estimate - double avg = total_coverage / threads; - est = (diff / avg * cov) - diff; - } - } - else - { - // calculate average coverage and use that to estimate - double avg = total_coverage / threads; - // round up to next multiple of 100 - cov = ((int)(avg / 100) + 1) * 100; - est = (diff / avg * cov) - diff; - } + est = (diff / total_coverage * cov) - diff; TimeSpan est_time = TimeSpan.FromMilliseconds(est); lbl_estimated_time.Text = String.Format("{0:00}h{1:00}m{2:00}s to {3}%", @@ -370,7 +350,7 @@ private void ud_win_height_ValueChanged(object sender, EventArgs e) // helper functions // returns free RAM in MB - private UInt64 get_free_ram() + private ulong get_free_ram() { /* * Available RAM = Free + Standby @@ -381,14 +361,15 @@ private UInt64 get_free_ram() * * Standby = Cached - Modifed */ - UInt64 avail = new ComputerInfo().AvailablePhysicalMemory; + /* float standby = new PerformanceCounter("Memory", "Cache Bytes").NextValue() + //new PerformanceCounter("Memory", "Modified Page List Bytes").NextValue() + new PerformanceCounter("Memory", "Standby Cache Core Bytes").NextValue() + new PerformanceCounter("Memory", "Standby Cache Normal Priority Bytes").NextValue() + new PerformanceCounter("Memory", "Standby Cache Reserve Bytes").NextValue(); + */ - return (UInt64)((avail - standby) / (1024 * 1024)); + return new ComputerInfo().AvailablePhysicalMemory / (1024 * 1024); } // TODO: error checking @@ -613,6 +594,13 @@ private bool validate_input() private void init_lst_coverage() { + /* + * stop flickering + * https://stackoverflow.com/a/15268338 + */ + var method = typeof(ListView).GetMethod("SetStyle", BindingFlags.Instance | BindingFlags.NonPublic); + method.Invoke(lst_coverage, new object[] { ControlStyles.OptimizedDoubleBuffer, true }); + for (int i = 0; i <= (int)cbo_threads.SelectedItem; i++) { string[] row = { i.ToString(), "-", "-" };