Performance Issue

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 6 08:11:57 PDT 2017


On Wednesday, 6 September 2017 at 14:38:39 UTC, Vino.B wrote:
> On Wednesday, 6 September 2017 at 10:58:25 UTC, Azi Hassan 
> wrote:
>> [...]
>
> Hi Azi,
>
>   Your are correct, i tried to implement the fold in a separate 
> small program as below, but not able to get the the required 
> output, when you execute the below program the output you get 
> is as below
>
> Output:
> [31460]
> [31460, 1344448]
> [31460, 1344448, 2277663]
> [31460, 1344448, 2277663, 2277663]
> [31460, 1344448, 2277663, 2277663, 31460]
>
> Setup:
>
> C:\\Temp\\TEST1\\BACKUP : This has 2 folder and 2 files in each 
> folder
> C:\\Temp\\TEST2\\EXPORT : This has 2 folder and 2 files in one 
> folder and  1 file in another folder
>
> Total files : 5
>
> Required output:
> [31460, 1344448] - Array 1 for the FS C:\\Temp\\TEST1\\BACKUP
> [2277663, 2277663, 31460] - Array 2 for the 
> C:\\Temp\\TEST2\\EXPORT
>
> import std.algorithm: filter, map, fold;
> import std.parallelism: parallel;
> import std.file: SpanMode, dirEntries, isDir;
> import std.stdio: writeln;
> import std.typecons: tuple;
> import std.path: globMatch;
> import std.array;
> void main () {
> 	ulong[] Alternate;
> 	string[] Filesys = ["C:\\Temp\\TEST1\\BACKUP", 
> "C:\\Temp\\TEST2\\EXPORT"];
> 	foreach(FFs; Filesys)
> 		{
> 			auto dFiles = dirEntries(FFs, SpanMode.shallow).filter!(a => 
> a.isDir).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)) {
> 								Alternate ~= f[0]; writeln(Alternate);
> 																}
> 								}
> 		}
> }
>
> From,
> Vino.B

Hi Azi,

   The required out is like below

[31460]  - Array 1 for folder 1(all files in Folder 1) of the FS 
C:\\Temp\\TEST1\\BACKUP
[1344448]  - Array 2 for folder 2(all files in Folder 2) of the 
FS C:\\Temp\\TEST1\\BACKUP
[2277663, 2277663]  - Array 3 for folder 1(all files in Folder 1) 
of the FS C:\\Temp\\TEST2\\EXPOR
[31460] - Array 4 for folder 2(all files in Folder 2) the FS 
C:\\Temp\\TEST2\\EXPORT


More information about the Digitalmars-d-learn mailing list