/[RomCheater]/trunk/RomCheater/Docking/FloatingMemorySearcher.cs
ViewVC logotype

Diff of /trunk/RomCheater/Docking/FloatingMemorySearcher.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/05 23:23:33	548
+++ trunk/RomCheater/Docking/FloatingMemorySearcher.cs	2013/06/06 01:41:45	549
@@ -1502,19 +1502,45 @@
                     else
                     {
                         Guid new_SearchGuid = SearchGuid;
-                        //int Last_Whole_Percent_Done = 0;
+                        int Last_Whole_Percent_Done = 0;
                         // need to get the address list
-                        using (SearchResultReader reader = new SearchResultReader(SearchGuid, true)) // delete the file on dispose
+                        using (SearchResultReader reader = new SearchResultReader(SearchGuid, true,SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation))) // delete the file on dispose
                         {
+                            uint[] reader_addresses = new uint[reader.ResultCount];
+
+                            // pre-populate the addresses array
+                            Stopwatch st_profiler_reader_addresses = new Stopwatch();
+                            st_profiler_reader_addresses.Start();
+                            int reader_address_index = 0;
+                            foreach (var k in reader.GetResultCollection())
+                            {
+                                
+                                if (SearchWorkerThread.CancellationPending) { st_profiler_reader_addresses.Stop(); break; }
+                                reader_addresses[reader_address_index] = k.Address;
+
+                                string message = string.Format(" -> Creating Address Array (0x{0} of 0x{1})", reader_address_index.ToString("X"), reader_addresses.Length.ToString("X"));
+                                double double_percent_done = 100.0 * (double)((double)reader_address_index / (double)reader_addresses.Length);
+                                int int_percent_done = (int)double_percent_done;
+                                if ((int_percent_done != Last_Whole_Percent_Done))// && (reader_address_index % 10000) == 0)
+                                {
+                                    UpdateProgress((int)double_percent_done, message);
+                                    Last_Whole_Percent_Done = int_percent_done;
+                                    logger.Profiler.WriteLine("It has taken {0} seconds to pre-populate the address array.", st_profiler_reader_addresses.Elapsed.TotalSeconds);
+                                }
+
+                                reader_address_index++;
+                            }
+                            st_profiler_reader_addresses.Stop();
+                            logger.Profiler.WriteLine("It took a total of {0} seconds to pre-populate the address array.", st_profiler_reader_addresses.Elapsed.TotalSeconds);
                             new_SearchGuid = GuidTools.IncrementGuid(SearchGuid);
                             using (SearchResultWriter writer = new SearchResultWriter(0, new_SearchGuid))
                             {
+                                Last_Whole_Percent_Done = 0;
                                 //int index = 0;
 
                                 provider.OpenProvider();
                                 //int count = (int)((MemoryRangeSize - MemoryRangeStart) / STEP_SIZE);
-                                //SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);
-                                int Last_Whole_Percent_Done = 0;
+                                //SearchResultWriter writer = new SearchResultWriter((int)(count), SearchGuid);                                
                                 uint size = 0;
                                 const uint MB_SIZE = 16; /* MEM_1MB * MB_SIZE = MB_SIZE in megabytes */
                                 switch (sdt)
@@ -1552,7 +1578,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1597,7 +1623,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1643,7 +1669,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1688,7 +1714,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1734,7 +1760,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1779,7 +1805,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1825,7 +1851,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -1870,7 +1896,7 @@
                                                 foreach (var Value in t_data)
                                                 {
                                                     if (SearchWorkerThread.CancellationPending) { break; }
-                                                    if (!reader.ContainsAddress(address_index, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                                                    if (!reader.ContainsAddress(address_index))
                                                     {
                                                         continue;
                                                     }
@@ -2575,7 +2601,7 @@
             UpdateProgress(100, String.Empty);
             //new Action<int, string>(UpdateProgress).Invoke(100, string.Empty);
             bool unsigned = SearchArgs.IsUnsignedDataType;
-            using (SearchResultReader reader = new SearchResultReader(SearchGuid))
+            using (SearchResultReader reader = new SearchResultReader(SearchGuid, SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
             {
                 logger.Info.WriteLine(string.Format("Found 0x{0:x8} results", reader.ResultCount));
 
@@ -2583,7 +2609,7 @@
                 {
                     lstResults.Items.Clear();
                     List<ResultItem> items = new List<ResultItem>();
-                    foreach (var k in reader.GetResults(SearchArgs.IsUnsignedDataType, SearchArgs.DataType, new Action<int, string>(UpdateProgress), new Func<bool>(ShouldCancelAnySearchOperation)))
+                    foreach (var k in reader.GetResultCollection())
                     {
                         switch (SearchArgs.DataType)
                         {

 

  ViewVC Help
Powered by ViewVC 1.1.22