Solved

FileVersionInfo.GetVersionInfo ().ProductVersion performance

Posted on 2003-10-22
3
1,142 Views
Last Modified: 2010-05-18
I have an app that calls FileVersionInfo.GetVersionInfo (<filename>).ProductVersion for all the files in a folder (90 files total).  

After rebooting my PC, the first time I run this app, the 90 calls take 5 seconds.  The second time they take .2 seconds.   Can anyone explain the performance difference.  Obviously something has been cached, but what?

The reason I'm asking is that our users turn on their PC in the morning, start this app and leave it running all day.  I'm trying to improve the startup performance of the app.
0
Comment
Question by:wile_e_coyote
3 Comments
 
LVL 28

Assisted Solution

by:iboutchkine
iboutchkine earned 63 total points
ID: 9600204
When you run the app the first time CLR under .NET Framework compiles the piece of code that you are running. THe second time if compilation was done before CLR does not do it. The more you will run your app under .NET Framework, the faster it will run up to the point where everything is compiled. The first time is the slowest
0
 
LVL 41

Accepted Solution

by:
graye earned 63 total points
ID: 9606164
yes, it could be the "just-in-time" compiler that's causing the effect.  But if so, that would only apply to very first time.  

On the other hand, it might just be the File System cache that's doing the trick...  files are cached up after the first run, making subsequent runs go much faster.

But let's talk about optimization...

You can use the FileSystemInfo object to pull all the "directory" information of the files in a folder into an array with a single call.  This *might* prime the pump to make calls to FileVersionInfo go faster (I haven't tried it)
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 23258867
I had the same effect in native Win32 code. It must be caused by the underlying Windows API.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now