123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using Xunit;
- namespace Bsm.Core.Tests
- {
- public class IoPoc
- {
- [Fact]
- public void CalcFileSizeA()
- {
- var dir = @"Y:\BeatSaverAll";
- long jsonSize = 0;
- var sw = new Stopwatch();
- sw.Restart();
- IoUtil.LookupFilesRecursively(dir, (p, f) =>
- {
- var ext = Path.GetExtension(p.cFileName)?.ToLower();
- if (ext != ".jpg" && ext!=".png") return;
- jsonSize += p.FileSize;
- });
- sw.Stop();//35s
- var kb = jsonSize / 1024f;
- var mb = kb / 1024f;
- var gb = mb / 1024f;
- }
- [Fact]
- public void CalcFileSizeB()
- {
- var dir = @"Z:\BeatSaverAll";
- var sw = new Stopwatch();
- sw.Restart();
- var jsonSize = Directory.GetFiles(dir, "*.dat", SearchOption.AllDirectories).Select(p => IoUtil.GetFileSize(p)).Sum();
- sw.Stop(); //2m0s
- var kb = jsonSize / 1024f;
- var mb = kb / 1024f;
- var gb = mb / 1024f;
- }
- }
- }
|