Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# C#4.0
I have a program that caches thumbnail images generated from a multi-page tiff. The performance on my development machine is terrible compared to other computers and a vm run within my dev machine. My development machine is what I would consider a pretty clean Win 7 x64 setup with a processor score of 7.3 per Windows Experience. I tested loading times on 3 different setups using a 250 page tiff file 5 times on each setup. The same exe and test tiff file were used. The exe was built using the Any CPU platform with Visual Studio 2010 Professional. I've tried compiling with various .net versions and platform changes with the same results. The results below were obtained using release builds built on .net 4.
 
Win 7 x64 (Intel Q9300 @ 3 GHz dev comp): 68515,68203,67985,68421,68328 = 68290 (ave ms)
Win XP x64 (virtual machine on dev comp): 21703,14890,17500,21015,15515 = 18125 (ave ms)
Win Vista x64 (different comp with slower CPU): 11466,11372,11450,11653,11325 = 11453 (ave ms)
Win XP x86 (Intel E8400 @ 3 GHz): 13391,13172,13062,13031,13047 = 13140.6 (ave ms)
 
The program was also used on my work computer (XP x86) with quick loading times, but I don't have numbers. I'm at a loss as to why the performance is so bad on my dev machine. I've tried disabling any program that could affect performance, but nothing works and Google has failed me.
 
I don't really have a specific question, but would appreciate any clues as to why this may be happening e.g. compiler settings, .net runtime settings, etc. I have no idea why a slower computer would be ~6x faster and a virtual machine within the problem computer is ~4x faster than running the program directly within the installed OS (Win 7).
 
Thanks in advance for any suggestions.
Posted 14-Mar-12 17:49pm
polarz186
Edited 16-Mar-12 4:03am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
it's really depending on your graphics card or rather the drivers, it sometimes help to try other/newer version.
WPF is using hardware accleration and if set, antialiasing.
Maybe you could increase performance by installing vmware tools, but some functions are still unavailable.
Here's a way how to customize the rendering settings of a wpf application to increase/adapt it to hardware configuration.
 
http://msdn.microsoft.com/en-us/library/aa970912.aspx[^]
 

With Best Regards
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Björn, thanks for your response. I'm skeptical it is a graphics card issue, but I am by no means an expert. I'm using the current AMD drivers and have a Raedon HD 6670 card. My app was created using the generic "Windows Forms Application" option in Visual Studio 2010. I'm not using any WPF features that I'm aware of. Below is my cache & load code. Only one image is loaded into a PictureBox and visible. The rest of the images are cached into an IList so I can access them quickly at a later time. I'm not a programmer by trade so if my implementation is not done well I'll take tips on that too Smile | :)
 
I'd like the program to work properly using only the .net runtime and do not want to require additional third party tools like vmware. Everything appears to work well on machines other than my dev machine. Any other suggestions are welcome. Thanks!
 
        private void loadImage(Image i)
        {
            p.Image = i.GetThumbnailImage((int)numericUpDown1.Value, (int)(numericUpDown2.Value), null, IntPtr.Zero);
        }
 
        delegate int cacheImagesD(string fileName);
        private int cacheImages(string fileName)
        {
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            image = Image.FromStream(fs);
 
            printPagesTotal = image.GetFrameCount(FrameDimension.Page);
 
            Invoke(spd, new object[] { printPagesTotal });
 
            for (int x = 0; x < printPagesTotal; x++)
            {
                image.SelectActiveFrame(FrameDimension.Page, x);
                MemoryStream byteStream = new MemoryStream();
                image.Save(byteStream, ImageFormat.Bmp);
                images.Add(Image.FromStream(byteStream));
 
                Invoke(upd);
            }
            fs.Close();
            return printPagesTotal;
        }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

okay, a radeon hd 6670 is more than enough for smooth rendering.
Except without using WPF I can't believe that it can be slower than on other (older) systems.
I don't mean that you require vmware, it's only a fact that applications doesn't run in vm as well as without using vm machines.
 
So my conclusion is similar with yours yet, if it's running smoothly with your other pc's (using the same setup,compiled as release version, not debug, same tiff file).
 
So I would try it on one more Win7 x64 and if it's running well, there must be something wrong with dev machine, but that's quite hard to say, can't have a look at your system configuration and your hdd.
 
Your code seems to work, I had a look over it and the only thing IMHO would change is using the using Statement with FileStream and Memorystream because of right Disposing() of the streams.
 
Please give a feedback to us, it's an interesting question for me Big Grin | :-D .
 
Regards
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Tried a couple different setups. Fresh install of Win 7 x64 SP1 on dev machine with no programs installed other than .net framework 4. Same results within 1% of the dev machine tests above. Fresh install Win 7 x64 on comparable computer with only .net framework 4 installed. Same slow results as dev machine. Numbers from my work computer were added above. Win XP x86 (Intel E8400 @ 3 GHz): 13391,13172,13062,13031,13047 = 13140.6 (ave ms)
 
Probably a big waste of my time to run tests on clean installs XP and Vista on my dev machine, but that would provide the most accurate comparison. Will give it a shot this weekend if I have time. Any additional suggestions are welcome.
 
Conclusion: I'm still stumped...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

You said you're loading a 250-page TIFF file five times - looks to me like it's a matter of hard drive access. This could be a result of a faulty controller on the motherboard, a dodgy cable, an inherently slow hard drive, or one that is heavily fragmented. It could even be cache settings in Windows (you listed four different versions).
  Permalink  
v2
Comments
Björn Ranft at 16-Mar-12 13:05pm
   
Hi, good points but if app runs faster in vm on same machine a faulty controller,corrupt cable or hard drive speed is out of question (in my opinion). Remains defragmentation,cache settings, buggy driver on host dev machine, ... a lot of watching the sandglass ;)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

The tests on my dev machine were done when the test tiff was placed on a ramdisk, but other tests run on that machine were done from a normal hard drive. The results were essentially identical. Several tests on a different computer with Win 7 x64 were done which yielded the same slow results. Each test was done independently. By independently I opened the program, ran a test, documented the results, closed the program and reopened it to start the next test. I'm confident this is not a hardware issue.
 
As far as a cache setting in Windows that is something I'd be interested in looking at. That gets back to my initial issue of why does Windows 7 perform significantly worse than other versions of Windows (XP & Vista). In essence is there some setting in Win 7 that is causing this?
 
Thanks for your feedback.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

It's possible to tweak Win7 through creating ramdisk, adapting pagefile.sys, cleaning registry (ccleaner), ... However it's useless if you reformatted,reinstalled your win, but that's not the real problem.
 
Here's a link to optimize win7:
http://programming4.us/desktop/2082.aspx[^]
 

I rereaded your solution 4 and you wrote:
Fresh install Win 7 x64 on comparable computer with only .net framework 4 installed. Same slow results as dev machine.
 
So for my understanding it's only slower in case Win 7 is installed?
 
If you get same (slow) result only with Windows 7 (on compareable hardware) I consider because Win7 uses some techniques which costs more performance than running under XP (in case there is no antivirus/other service is running). But it's not easy to say without testing it by self.
  Permalink  
v5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Based on the posts/articles below GDI+ was changed in Win 7 and is likely the cause of my problems. Unless I'm totally off base I'm going to have to use a technology other than starting with the Windows Forms Application in VS 2010 if I want consistent performance across all windows versions. Thanks for the comments.
 
http://www.windows7taskforce.com/view/3607[^]
 
http://www.pcpro.co.uk/blogs/2009/05/07/windows-7-gdi-performance-the-big-trade-off/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 195
2 Afzaal Ahmad Zeeshan 154
3 Zoltán Zörgő 149
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,994
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 18 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100