Performance Issue

user1234 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 6 02:54:46 PDT 2017


On Tuesday, 5 September 2017 at 09:44:09 UTC, Vino.B wrote:
> Hi,
>
>  The below code is consume more memory and slower can you 
> provide your suggestion on how to over come these issues.
>
> string[][] csizeDirList (string FFs, int SizeDir) {
> 	ulong subdirTotal = 0;
> 	ulong subdirTotalGB;
> 	auto Subdata = appender!(string[][]);
>     auto dFiles = dirEntries(FFs, SpanMode.shallow).filter!(a 
> => a.isDir && !globMatch(a.baseName, "*DND*")).map!(a => 
> tuple(a.name, a.size)).array;
> 	  foreach (d; dFiles) {
> 				auto SdFiles = dirEntries(join(["\\\\?\\", d[0]]), 
> SpanMode.depth).map!(a => tuple(a.size)).array;
> 				foreach (f; parallel(SdFiles,1))
> 					{ subdirTotal += f[0]; }
> 						subdirTotalGB = (subdirTotal/1024/1024);
> 						if (subdirTotalGB > SizeDir) { Subdata ~= [d[0], 
> to!string(subdirTotalGB)]; }
> 						subdirTotal = 0;
> 		    }
> 			return Subdata.data;
> }
>
> From,
> Vino.B

Try to suppress the globMatch. according to the glob, just a 
ctRegex would do the job or even more simple `!a.canFind("DND")`.


More information about the Digitalmars-d-learn mailing list