Posts Tagged ‘Performance’

Today I faced some spyware attack on my machine and it totally controlled my machine where I can’t run any exe based program like browsers, installables, visual studio, cmd … etc

I struggled for some time and finally resolved it by doing following steps …

I tried to notice what process is running when I run any exe based program and I found it as nuk.exe. I tried to find the exe location thru process properties in task manager and then I killed all nuk.exe based processes. Later I have renamed the nuk.exe to nuk.exe.txt to stop it running on opening any exe based program. Later I deleted it.

After that I installed following spyware trail version software (Webroot SecurityAnywhere) from webroot and scanned the pc and removed threats.

http://www.webroot.com/En_US/sites/bbi/sem-wsaav-fp/?semcid=BTC_US_Non-Branded+Antispyware-Spyware+Remover-spyware%20removal%20tools

After that I installed Advanced SystemCare Free software and cleaned up malware, registry, shortcuts, history and junk files.

http://pcsupport.about.com/od/toolsofthetrade/tp/free-registry-cleaner-programs.htm

http://www.codeproject.com/KB/web-cache/CachingDependencies.aspx

http://www.blaze.io/mobile/http-pipelining-big-in-mobile/

http://www.brianp.net/2011/07/19/will-http-pipelining-help-a-study-based-on-the-httparchive-org-data-set/

http://encosia.com/11-keystrokes-that-made-my-jquery-selector-run-10x-faster/

http://msdn.microsoft.com/en-US/scriptjunkie/hh273390.aspx

1. Centralized event handling

This will be used in cases where we have a number of similar elements or structures on a page that share similar behaviour when a user-action is performed against them.

In JavaScript, there’s a known bubbling effect in the language so that if an element such as a link or button is clicked, that event is bubbled up to the parent, informing them that something lower down the tree has been clicked. We can use this effect to our advantage.

Ex: In following example we can bind click event to ul and can handle every li click separately with out binding different functions directly to each li. This will also improve performance by minimizing the DOM access for binding/unbinding and by avoiding the event handling for each element separately.

<ul>
 <li class=’one’>One</li>
 <li class=’two’>two</li>
 <li class=’three’>three</li>
 <li class=’four’>four</li>
 <li class=’five’>five</li>
</ul>

stateManager = {
    fly: function () {
        var self = this;
        $(‘ul’).unbind().bind(“click”, function (e) {
            var target = $(e.originalTarget || e.srcElement);
            if (target.is(“li.one”)) {
                self.handleLIOne(target[0]);
            }
            else if (target.is(“li.two”)) {
                self.handleLITwo(target[0]);
            }
        });
    },
    handleLIOne: function (elem) {
        //Do your own implementation for first li element click
        alert(elem.innerHTML);
    },
    handleLITwo: function (elem) {
        //Do your own implementation for second li element click
        alert(elem.innerHTML);
    }
}
stateManager.fly();

Use JavaScriptSerializer to convert JSON object to C# object and backwards. It is very useful to build AJAX based web pages for thinner network traffic and for better client side html computation …

using System.Web.Script.Serialization;

public class Employee
{
 public string Name { get; set; }
        public string Age { get; set; }
        public string ID { get; set; }
}

Employee oEmployee1 = new Employee { Name = “name1”, ID = “1”, Age = “5” };
Employee oEmployee2 = new Employee { Name = “name2”, ID = “2”, Age = “7” };
Employee oEmployee3 = new Employee { Name = “name3”, ID = “3”, Age = “8” };
List<Employee> oList = new List<Employee>() { oEmployee1, oEmployee2, oEmployee3 };

JavaScriptSerializer oSerializer = new JavaScriptSerializer();
string sJSON = oSerializer.Serialize(oList);
Response.Write(sJSON);
List<Employee> oNewList = (List<Employee>)oSerializer.Deserialize(sJSON, typeof(List<Employee>));
Response.Write(oNewList.Count + “”);

string sJSON2 = oSerializer.Serialize(oEmployee1);
Response.Write(sJSON2);
Employee emp = (Employee)oSerializer.Deserialize(sJSON2, typeof(Employee));
Response.Write(emp.Name + “”);

Are you worried with query performance due to huge data in tables, use Table partitioning of SQL Server 2008. It’s easy and very useful.

You can partition data to different db data files stored in different hard disks on the server to increase parallelism with I/O. It’s been simplified in SQL Server 2008 compared to SQL Server 2005/2000. We can use wizard based or script based approach to create partitions on new or existing tables. Refer following links for more info.

Track your page/website’s traffic …

http://chartbeat.com/

http://getclicky.com/

http://www.google.com/analytics/

Entity Framework Vs Linq To SQL Vs NHibernate Vs few more …

http://ormeter.net/

ORMs across Languages …

http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software

What is ORM?

http://en.wikipedia.org/wiki/Object-relational_mapping

Performance impact of iFrame

Posted: February 17, 2011 in Performance
Tags: , ,

Avoid using iframe for performance reasons, read more @

http://www.stevesouders.com/blog/2009/06/03/using-iframes-sparingly/

Using this in some places can not be avoided like if we want to access an https url from a http page which is not accepted. So for handling authentication on AJAX from a http page needs a blank iframe with action to https page and method attribute. AJAX request will be submitted to iframe (intern https url, can be .net generic handler) and on server set the cookies and return the blank response to iframe and on window onload event of iframe we can do neccessary changes on parent page by directly accessing cookies through javascript to know authentication success or failure.