PowerToys/Wox.Test/MFTSearcherTest.cs

49 lines
2.1 KiB
C#
Raw Normal View History

2014-10-22 22:49:34 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
2014-10-27 18:22:25 +08:00
using Wox.Plugin.FindFile.MFTSearch;
2014-10-22 22:49:34 +08:00
namespace Wox.Test
{
[TestFixture]
public class MFTSearcherTest
{
[Test]
public void MatchTest()
{
var searchtimestart = DateTime.Now;
MFTSearcher.IndexAllVolumes();
var searchtimeend = DateTime.Now;
2014-10-23 23:23:40 +08:00
Console.WriteLine(string.Format("{0} file indexed, {1}ms has spent.", MFTSearcher.IndexedFileCount, searchtimeend.Subtract(searchtimestart).TotalMilliseconds));
2014-10-22 22:49:34 +08:00
searchtimestart = DateTime.Now;
List<MFTSearchRecord> mftSearchRecords = MFTSearcher.Search("q");
searchtimeend = DateTime.Now;
Console.WriteLine(string.Format("{0} file searched, {1}ms has spent.", mftSearchRecords.Count, searchtimeend.Subtract(searchtimestart).TotalMilliseconds));
searchtimestart = DateTime.Now;
mftSearchRecords = MFTSearcher.Search("ss");
searchtimeend = DateTime.Now;
Console.WriteLine(string.Format("{0} file searched, {1}ms has spent.", mftSearchRecords.Count, searchtimeend.Subtract(searchtimestart).TotalMilliseconds));
}
2014-10-23 18:39:11 +08:00
[Test]
public void MemoryTest()
{
long oldWorkingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
MFTSearcher.IndexAllVolumes();
2014-10-23 23:23:40 +08:00
GC.Collect();
2014-10-23 18:39:11 +08:00
long newWorkingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
Console.WriteLine(string.Format("Index: {0}M", (newWorkingSet - oldWorkingSet)/(1024*1024)));
oldWorkingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
List<MFTSearchRecord> mftSearchRecords = MFTSearcher.Search("q");
2014-10-23 18:39:11 +08:00
newWorkingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
Console.WriteLine(string.Format("Search: {0}M", (newWorkingSet - oldWorkingSet) / (1024 * 1024)));
Console.WriteLine(string.Format("Search results: {0}",mftSearchRecords.Count));
2014-10-23 18:39:11 +08:00
}
2014-10-22 22:49:34 +08:00
}
}