2017-08-17 3 views
0

J'ai quelques fichiers modèles hébergés en plusieurs endroits, la raison principale est d'avoir pour chaque module le modèle correspondant accessible localement. Par la suite, je me suis rendu compte que ces fichiers étaient utilisés via le chemin partagé UNC pour chaque boîte.Y at-il une différence de performance entre l'accès à un fichier via un chemin local ou un chemin partagé UNC?

Ma question est: Existe-t-il une différence de performance entre l'accès aux fichiers locaux via le chemin local et le chemin UNC?

+0

oui, bien sûr, lorsque vous accédez à des fichiers via le chemin local, cela sera plus rapide et plus efficace plutôt que vers un chemin UNC. combien - déjà une autre question. mais plus vite – RbMm

+0

Oui, je sais, mais c'est une question de combien. J'ai fait quelques expériences et les résultats sont assez similaires. – Miguel

+0

Peut-être, c'est seulement comme ça pour .Net parce que Microsoft désambiguise à un moment donné. Peut-être que c'est différent quand testé en C, C++. – Miguel

Répondre

1

On dirait que la surcharge est minimale. J'ai couru des tests chronométrés en utilisant le code suivant:

var localTimes = new List<long>(); 
var sharedTimes = new List<long>(); 

var stopwatch = new Stopwatch(); 
for (int i = 0; i < 1000; i++) 
{ 
    stopwatch.Start(); 
    var bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"E:\Shared\Template.xlsx"); 
    stopwatch.Stop(); 

    localTimes.Add(stopwatch.ElapsedTicks); 

    stopwatch.Start(); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    bytes = File.ReadAllBytes(@"\\localhost\Shared\Template.xlsx"); 
    stopwatch.Stop(); 

    sharedTimes.Add(stopwatch.ElapsedTicks); 
} 

Console.WriteLine("Local: avg={0}, 50k={1}", TimeSpan.FromTicks((long)localTimes.Average()/50), TimeSpan.FromTicks(localTimes.Sum())); 
Console.WriteLine("Shared: avg={0}, 50k={1}", TimeSpan.FromTicks((long)sharedTimes.Average()/50), TimeSpan.FromTicks(sharedTimes.Sum())); 

et ce sont les résultats:

Local: avg = 00: 00: 00,0567284, 50k = 00: 47: 16,4212917

partagés: avg = 00: 00: 00.0568292, 50k = 00: 47: 21.4612018

Mes conclusions sont que cela n'a pas d'importance.