Pages

Powered by Blogger.
 
Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts
Tuesday, June 7, 2011
Title:
Optimizing Your Asp.Net Pages for Faster Loading and Better Performance.


If you read the internet and all of the websites dedicated to Asp.Net you will inevitably read about the wonders of the DataGrid, DataList, and Repeater controls. While each of these has its place, if you are only displaying data there is a much faster and more efficient means to do so.

If you read the internet and all of the websites dedicated to Asp.Net you will inevitably read about the wonders of the DataGrid, DataList, and Repeater controls. While each of these has its place, if you are only displaying data there is a much faster and more efficient means to do so.

Let's say you have a page that displays articles based on a query string. Take my article pages for instance. Each article is stored in a database and displayed on the page based on the unique id of the article as stored in the database.

A normal asp page execution procedure goes something like this. The code queries the database based on the Article I.D. and then brings back that information to the page where you display it in the fashion that you would like. This is a fairly straight forward approach with asp and is done all the time.

So how do we speed up our asp.net pages?

Number 1: Use Asp.Net Caching!

This is a no-brainer, and I won't go into the brilliance or details of asp.net caching here because at the time of this writing Google has 2,780,000 articles on the topic. Basically instead of querying the database each time the page is loaded you only query the database once and load that result into the system cache. Subsequent calls to load the page retrieve the data from the cache as opposed to the database which gives you an instant and considerable performance boost. You can then set the cache for how long the cache should store the information as well as many other features. If you are not using the cache, you should be whenever possible!

Number 2: If possible, do NOT use the standard Asp.Net controls.

That's right. The standard asp.net controls are designed for rapid development and not page performance. They allow you to design pages that grab and display data very quickly but their actual performance suffers because of the extra overhead which is there for ease and speed of development time and not page execution speed.

Instead, create either a User Control or even better yet a Web Custom Control which is by far the fastest performance wise and really quite easy to create and use.

Number 3: Use an SqlDataReader or even better yet use a set based command for Sql Server data retrieval and simply execute that one command against the database.

An asp.net SqlDataReader is a fast forward only datareader that closes the connection after it reads the last set of results. Now for my article pages we are only returning 1 particular result. In this case we would opt for the set based command. If you had more than 1 result returned, in your table of contents for instance, you would use the SqlDataReader because you are returning multiple results.

Set based commands are stored procedures that bring back data through parameters as opposed to a result set which then in turn needs to be looped through to obtain your data. So instead of writing your stored procedure like the following which brings back 1 result set:

Select Title, Body, Author
From Articles
Where ArtID = 215

We can write it using a set based command like this.

Create Procedure mysp_GetArticle

@Title varchar(200) Output,
@Body varchar(8000) Output,
@Author varchar(500) Output

As

Select @Title = Title, @Body = Body, @Author = Author
From Articles
Where ArtID = 215

GO

The above query will return only the three parameters called for and not a result or record set so you don't have to then walk through the returned record set that has only 1 result in it anyway. This second little process of work decreases your performance so do not use it if you can. Combine this technique with the asp.net cache.

Number 4: Use Classes and ArrayLists as opposed to returning an SqlDataReader.

Create a class and then if there are more than one set of results store those results into individual instantiations of that class. Finally store each of those classes into an ArrayList. You can then store only that ArrayList into the asp.net cache. So instead of getting the results back from a SqlDataReader when loading your page you get them from the ArrayList which is stored in the cache. Nice huh?

Finally... you want to incorporate all of these techniques into your final results which would be performed in the following manner and sequence.

On the first time the page loads, query the database and return all of your data storing it into individual classes. Then store each of those classes into an ArrayList. If you only have one single result you may store only the class into the cache. Then take your ArrayList and store it into the cache.

Next create a Web Custom Control and pass the cached ArrayList to the custom control and loop out your data using the HtmlTextWriter which is very fast. Remember each subsequent call to load the page will be called from the cache which stores your ArraList of classes or your single class.

Certainly it takes a significant amount of additional coding to do it in this fashion, especially when you take proper error handling into consideration, but if you follow this approach your pages will be screeching fast, you will immediately notice the difference, and your asp.net pages will execute in the proper sequence - Data handling in the Page_Load function and the html display in the Page_Render function. Further, you will be glad you did and so will your visitors.

Happy Programming!
Sunday, May 1, 2011

Boost Windows XP Performance with Flash Memory

Give your Windows XP the same performance benefits as provided by Microsoft ReadyBoost, only without its limitations! eBoostr enables Windows XP using flash memory to increase system speed.
Have you read about Microsoft ReadyBoost technology in the press, but are disappointed it didn't make its way into Windows XP? Are you reluctant to upgrade your PC or operating system, but wish for the increased responsiveness and performance benefits provided by ReadyBoost? Get eBoostr (http://www.eboostr.com/) and give your Windows XP the same performance benefits as provided by Microsoft ReadyBoost, only without its limitations!

ReadyBoost is one of the core technologies implemented by Microsoft in Windows Vista. The new technology solves a bottleneck typical for many PCs when upgrading to a new Microsoft operating system: the lack of memory. It is no secret that every new operating system released by Microsoft is more memory-hungry than the one it replaces. With ReadyBoost technology built into its latest generation of operating systems, Windows Vista, Microsoft attempted to address this problem. This time they did it by allowing using cheap flash memory such as USB memory sticks or memory cards typically found in digital cameras to expand the amount of memory available to the system, reducing hard drive access and improving overall system performance and application responsiveness.

ReadyBoost is a great technology when you're low on RAM. The problem is that ReadyBoost is only available in Windows Vista and it never made it to its older sibling, Windows XP. Computers using Windows XP are older than those sold with pre-installed Windows Vista. In general, they have less memory installed, and would benefit from using ReadyBoost even more than the modern machines. Alas, ReadyBoost will not be available unless you pull the trigger and upgrade to Windows Vista.

Is there a real necessity to call for such drastic measures to get a performance boost? No! MDO Ltd. has released a replacement for Microsoft ReadyBoost technology - only this time it works on Windows XP machines!

eBoostr (http://www.eboostr.com/) does everything that Microsoft ReadyBoost can do. It replaces relatively slow access to hard disk by fast one to flash memory, allowing you to use up to four different flash devices, and provides the same benefits of increased system performance, improved application load times and better overall responsiveness.

eBoostr is even more useful than ReadyBoost as it does not place strict performance requirements on the flash memory you use to speed up your system. While ReadyBoost requires you to use faster and more costly memory cards, eBoostr can work with just about every inexpensive flash drive on the market. Unlike ReadyBoost, eBoostr supports up to four flash devices at the same time, a real breath of fresh air after ReadyBoost which supports just one. Finally, eBoostr enhances the performance of slower PCs as well as computers with lots of RAM, while ReadyBoost mostly benefits slower PCs with a limited amount of memory.

Do you have a laptop computer with a built-in card reader or a free USB port? Plug a memory card or a flash drive into your laptop and enjoy increased system performance and longer battery life! It's no secret that mobile hard drives used in notebook computers are much slower than their desktop counterparts. eBoostr reduces the amount of hard drive activity, which results in even greater performance benefits than on the bigger desktops, while at the same time reducing the amount of energy required to drive the laptop, allowing your notebook to survive longer on a single battery charge.

Grab the nearest flash card, install eBoostr (http://www.eboostr.com/) and start enjoying increased system performance and application responsiveness immediately!
Saturday, April 30, 2011
10 Simple Ways To Speed Up Your Windows XP
Many people are interested in making the most of their hardware. So here are 10 simple tips on how to make your Windows XP computer run faster without having to purchase additional hardware.
1. Defrag Disk to Speed Up Access to Data

One of the factors that slow the performance of the computer is disk fragmentation. When files are fragmented, the computer must search the hard disk when the file is opened to piece it back together. To speed up the response time, you should monthly run Disk Defragmenter, a Windows utility that defrags and consolidates fragmented files for quicker computer response.

* Follow Start > All Programs > Accessories > System Tools > Disk Defragmenter
* Click the drives you want to defrag and click Analyze
* Click Defragment

2. Detect and Repair Disk Errors

Over time, your hard disk develops bad sectors. Bad sectors slow down hard disk performance and sometimes make data writing difficult or even impossible. To detect and repair disk errors, Windows has a built-in tool called the Error Checking utility. It’ll search the hard disk for bad sectors and system errors and repair them for faster performance.

* Follow Start > My Computer
* In My Computer right-click the hard disk you want to scan and click Properties
* Click the Tools tab
* Click Check Now
* Select the Scan for and attempt recovery of bad sectors check box
* Click Start

3. Disable Indexing Services

Indexing Services is a little application that uses a lot of CPU. By indexing and updating lists of all the files on the computer, it helps you to do a search for something faster as it scans the index list. But if you know where your files are, you can disable this system service. It won’t do any harm to you machine, whether you search often or not very often.

* Go to Start
* Click Settings
* Click Control Panel
* Double-click Add/Remove Programs
* Click the Add/Remove Window Components
* Uncheck the Indexing services
* Click Next
4. Optimize Display Settings

Windows XP is a looker. But it costs you system resources that are used to display all the visual items and effects. Windows looks fine if you disable most of the settings and leave the following:

* Show shadows under menus
* Show shadows under mouse pointer
* Show translucent selection rectangle
* Use drop shadows for icons labels on the desktop
* Use visual styles on windows and buttons

5. Speedup Folder Browsing

You may have noticed that everytime you open My Computer to browse folders that there is a little delay. This is because Windows XP automatically searches for network files and printers everytime you open Windows Explorer. To fix this and to increase browsing speed, you can disable the “Automatically search for network folders and printers” option.

6. Disable Performance Counters

Windows XP has a performance monitor utility which monitors several areas of your PC’s performance. These utilities take up system resources so disabling is a good idea.

* Download and install the Extensible Performance Counter List(http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/exctrlst-o.asp)
* Then select each counter in turn in the ‘Extensible performance counters’ window and clear the ‘performance counters enabled’ checkbox at the bottom button below

7. Optimize Your Pagefile

You can optimize your pagefile. Setting a fixed size to your pagefile saves the operating system from the need to resize the pagefile.

* Right click on My Computer and select Properties
* Select the Advanced tab
* Under Performance choose the Settings button
* Select the Advanced tab again and under Virtual Memory select Change
* Highlight the drive containing your page file and make the initial Size of the file the same as the Maximum Size of the file.

Windows XP sizes the page file to about 1.5X the amount of actual physical memory by default. While this is good for systems with smaller amounts of memory (under 512MB) it is unlikely that a typical XP desktop system will ever need 1.5 X 512MB or more of virtual memory. If you have less than 512MB of memory, leave the page file at its default size. If you have 512MB or more, change the ratio to 1:1 page file size to physical memory size.

8. Remove Fonts for Speed

Fonts, especially TrueType fonts, use quite a bit of system resources. For optimal performance, trim your fonts down to just those that you need to use on a daily basis and fonts that applications may require.

* Open Control Panel
* Open Fonts folder
* Move fonts you don’t need to a temporary directory (e.g. C:\FONTBKUP?) just in case you need or want to bring a few of them back. The more fonts you uninstall, the more system resources you will gain.

9. Use a Flash Memory to Boost Performance

To improve performance, you need to install additional RAM memory. It’ll let you boot your OS much quicker and run many applications and access data quicker. There is no easiest and more technically elegant way to do it than use eBoostr (http://www.eboostr.com).

eBoostr is a little program that lets you improve a performance of any computer, powered by Windows XP in much the same way as Vista’s ReadyBoost. With eBoostr, if you have a flash drive, such as a USB flash thumb drive or an SD card, you can use it to make your computer run better. Simply plug in a flash drive through a USB socket and Windows XP will use eBoostr to utilize the flash memory to improve performance.

The product shows the best results for frequently used applications and data, which becomes a great feature for people who are using office programs, graphics applications or developer tools. It’ll surely attract a special attention of laptop owners as laptop upgrade is usually more complicated and laptop hard drives are by definition slower than those of desktops.

10. Perform a Boot Defragment

There's a simple way to speed up XP startup: make your system do a boot defragment, which will put all the boot files next to one another on your hard disk. When boot files are in close proximity to one another, your system will start faster.

On most systems, boot defragment should be enabled by default, but it might not be on yours, or it might have been changed inadvertently. To make sure that boot defragment is enabled:

* Run the Registry Editor
* Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction
* Set the Enable string value to Y if it is not already set to Y.
* Exit the Registry
* Reboot

Hope you find these 10 tips useful. Have a nice day!

Updates Via E-Mail

Labels