PDA

View Full Version : [OPEN] [#272] Ran some basic performance tests...



michaeld
Jun 05, 2013, 3:36 AM
I found a lot of time spend in unnecessary format calls. These are minor improvements but very obvious tweaks. I saw a 1-5% improvement. Mind checking these changes in?



Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/BaseControl/IScriptable.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/BaseControl/IScriptable.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/BaseControl/IScriptable.cs (working copy)
@@ -394,12 +394,14 @@
{
if (arg is string)
{
- sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.SafeResourceManager ));
- }
+ sb.Append( TokenUtils.ParseAndNormalize( arg.ToString(), this.SafeResourceManager ) );
+ }
else
{
- sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append( JSON.Serialize( arg, JSON.ScriptConverters ) );
}
+ sb.Append( ',' );
+
}
}

Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/DirectMethod.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/DirectMethod.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Core/DirectMethod.cs (working copy)
@@ -249,30 +249,34 @@

if (this.Method.IsStatic)
{
- sb.Append(needComma ? "," : "");
- sb.Append("specifier:\"static\"");
- sb.AppendFormat(",url:{0}", JSON.Serialize(url));
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "specifier:\"static\",url:" );
+ sb.Append(JSON.Serialize(url));
needComma = true;
}

if (controlID.IsNotEmpty())
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("control:\"{0}\"", controlID);
+ if( needComma )
+ sb.Append( ',' );
+ sb.AppendFormat( "control:\"{0}\"", controlID );
needComma = true;
}

if (this.Attribute.Method == HttpMethod.GET)
{
- sb.Append(needComma ? "," : "");
- sb.Append("method:\"GET\"");
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "method:\"GET\"" );
needComma = true;
}

if (this.Attribute.ShowMask)
{
- sb.Append(needComma ? "," : "");
- sb.Append("eventMask:{showMask:true");
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "eventMask:{showMask:true" );

if (this.Attribute.Msg.IsNotEmpty())
{
@@ -314,79 +318,99 @@

if (this.Attribute.Type == DirectEventType.Load)
{
- sb.Append(needComma ? "," : "");
- sb.Append("type:\"load\"");
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "type:\"load\"" );
needComma = true;
}

if (this.Attribute.ViewStateMode != ViewStateMode.Inherit)
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInv ariant());
+ if( needComma )
+ sb.Append( ',' );
+ sb.AppendFormat( "viewStateMode:\"{0}\"", this.Attribute.ViewStateMode.ToString().ToLowerInv ariant() );
needComma = true;
}

if (this.Attribute.RethrowException)
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("rethrowException:{0}", this.Attribute.RethrowException.ToString().ToLower Invariant());
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "rethrowException:" );
+ sb.Append(this.Attribute.RethrowException.ToString ().ToLowerInvariant());
needComma = true;
}


if (this.Attribute.Timeout != 30000)
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("timeout:{0}", this.Attribute.Timeout);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "timeout:" );
+ sb.Append(this.Attribute.Timeout);
needComma = true;
}

if (!this.Attribute.DisableCaching)
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("disableCaching:{0}", this.Attribute.DisableCaching.ToString().ToLowerIn variant());
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "disableCaching:" );
+ sb.AppendFormat(this.Attribute.DisableCaching.ToSt ring().ToLowerInvariant());
needComma = true;
}

if (!this.Attribute.Async)
{
- sb.Append(needComma ? "," : "");
+ if(needComma)
+ sb.Append(',');
sb.Append("async:false");
needComma = true;
}

if (this.Attribute.DisableCachingParam != "_dc")
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("disableCachingParam:{0}", this.Attribute.DisableCachingParam);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append("disableCachingParam:");
+ sb.Append( this.Attribute.DisableCachingParam );
needComma = true;
}

if (this.Attribute.SuccessFn.IsNotEmpty())
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("success:{0}", this.Attribute.SuccessFn);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "success:" );
+ sb.Append( this.Attribute.SuccessFn );
needComma = true;
}

if (this.Attribute.CompleteFn.IsNotEmpty())
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("complete:{0}", this.Attribute.CompleteFn);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append( "complete:" );
+ sb.Append( this.Attribute.CompleteFn );
needComma = true;
}

if (this.Attribute.FormID.IsNotEmpty())
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("formId:{0}", this.Attribute.FormID);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append("formId:");
+ sb.Append( this.Attribute.FormID );
needComma = true;
}

if (this.Attribute.FailureFn.IsNotEmpty())
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("failure:{0}", this.Attribute.FailureFn);
+ if( needComma )
+ sb.Append( ',' );
+ sb.Append("failure:");
+ sb.Append( this.Attribute.FailureFn );
+ needComma = true;
}

this.AppendParams(sb, needComma);



Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/SimpleStore.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/SimpleStore.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/SimpleStore.cs (working copy)
@@ -71,7 +71,8 @@
{
foreach (object arg in args)
{
- sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append(JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append( ',' );
}
}

Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/Tree/NodeProxy.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/Tree/NodeProxy.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Data/Tree/NodeProxy.cs (working copy)
@@ -194,7 +194,8 @@
{
foreach (object arg in args)
{
- sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append(JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append( ',' );
}
}




Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Dom/DomHelper.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Dom/DomHelper.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Dom/DomHelper.cs (working copy)
@@ -169,13 +169,14 @@
{
if (arg is string)
{
- sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), ResourceManager.GetInstance(HttpContext.Current))) ;
- }
+ sb.Append(TokenUtils.ParseAndNormalize(arg.ToStrin g(), ResourceManager.GetInstance(HttpContext.Current))) ;
+ }
else
{
- sb.AppendFormat("{0},", JSON.Serialize(arg));
+ sb.Append(JSON.Serialize(arg));
}
- }
+ sb.Append( ',' );
+ }
}
return sb.ToString().LeftOfRightmostOf(',');
}

Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Util/Observable.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Util/Observable.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Ext/Util/Observable.cs (working copy)
@@ -396,13 +396,16 @@
{
var sb = new StringBuilder(256);

- sb.AppendFormat("{0},", JSON.Serialize(eventName));
+ sb.Append(JSON.Serialize(eventName));
+ sb.Append( ',' );

+
if (args != null && args.Length > 0)
{
foreach (object arg in args)
{
- sb.AppendFormat("{0},", JSON.Serialize(arg));
+ sb.Append(JSON.Serialize(arg));
+ sb.Append( ',' );
}
}




Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/MVC/DirectMethods/MvcDirectMethod.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/MVC/DirectMethods/MvcDirectMethod.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/MVC/DirectMethods/MvcDirectMethod.cs (working copy)
@@ -233,7 +233,7 @@
{
if (needComma)
{
- sb.Append(",");
+ sb.Append(',');
}
method.UrlHelper = urlHelper;
method.GenerateProxy(sb, null, null);
@@ -242,10 +242,10 @@

if (scopeName.IsNotEmpty())
{
- sb.Append("}");
+ sb.Append('}');
}

- sb.Append(",");
+ sb.Append(',');
}

if (sb[sb.Length - 1] == ',')
@@ -302,8 +302,10 @@

protected override void AppendParams(StringBuilder sb, bool needComma)
{
- sb.Append(needComma ? "," : "");
- sb.AppendFormat("url:{0}", JSON.Serialize(this.ActionUrl));
+ if(needComma)
+ sb.Append( ',' );
+ sb.Append("url:");
+ sb.AppendFormat(JSON.Serialize(this.ActionUrl));
}
}
}


Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/JFunction.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/JFunction.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/JFunction.cs (working copy)
@@ -152,7 +152,8 @@
{
foreach (object arg in args)
{
- sb.AppendFormat("{0},", JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append(JSON.Serialize(arg, JSON.ScriptConverters));
+ sb.Append( ',' );
}
}

Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/Parameters/ParameterCollection.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/Parameters/ParameterCollection.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/Parameters/ParameterCollection.cs (working copy)
@@ -138,7 +138,8 @@

foreach (Parameter parameter in this)
{
- sb.AppendFormat("{0},", TokenUtils.ParseTokens(parameter.ToString(camelNam es), parameter.Owner));
+ sb.Append( TokenUtils.ParseTokens(parameter.ToString(camelNam es), parameter.Owner));
+ sb.Append( ',' );
removeComma = true;
}

Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/ContentScriptBuilder.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/ContentScriptBuilder.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/ContentScriptBuilder.cs (working copy)
@@ -108,7 +108,8 @@
sb.AppendFormat("Ext.suspendLayouts();", this.Control.ClientID);
if (container != null)
{
- sb.AppendFormat("{0}.removeAll();", this.Control.ClientID);
+ sb.Append( this.Control.ClientID );
+ sb.Append( ".removeAll();" );
}

List<BaseControl> childControls = this.FindControls(this.Control, selfRendering, sb, null, null);
@@ -215,7 +216,8 @@

if (container != null && container.Items.Count > 0)
{
- sb.AppendFormat("{0}.updateLayout();", this.Control.ClientID);
+ sb.Append( this.Control.ClientID );
+ sb.Append( ".updateLayout();" );
}

sb.AppendFormat("Ext.resumeLayouts(true);", this.Control.ClientID);





Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/DefaultScriptBuilder.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/DefaultScriptBuilder.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptBuilders/DefaultScriptBuilder.cs (working copy)
@@ -195,7 +195,8 @@
if (mode == RenderMode.AddTo || mode == RenderMode.InsertTo)
{
string elementGet = element.Contains(".") ? element : "Ext.getCmp({0})".FormatWith(JSON.Serialize(element));
- sb.AppendFormat("{0}.removeAll();", elementGet);
+ sb.Append( elementGet );
+ sb.Append( ".removeAll();" );
}
else if(mode != RenderMode.Replace)
{



Index: C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptClass.cs
================================================== =================
--- C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptClass.cs (revision 5171)
+++ C:/Users/Michael/Documents/Visual Studio 2012/Projects/Ext.Net/Ext.Net/Utility/ScriptClass.cs (working copy)
@@ -147,12 +147,14 @@
{
if (arg is string)
{
- sb.AppendFormat("{0},", TokenUtils.ParseAndNormalize(arg.ToString(), this.ResourceManager));
+ sb.Append(TokenUtils.ParseAndNormalize(arg.ToStrin g(), this.ResourceManager));
}
else
{
- sb.AppendFormat("{0},", JSON.Serialize(arg));
+ sb.Append(JSON.Serialize(arg));
}
+ sb.Append( ',' );
+
}
}

michaeld
Jun 06, 2013, 3:43 AM
BTW, line 188 (forum code line numbers) is missing in the trunk code and is a bug because needComma is passed to the next function if any text exists. If its not set in that condition, it will cause a failure in the next function if its the only condition that passes the conditional text pass.

Daniil
Jun 06, 2013, 3:42 PM
Hi @michaeld,

Thank you! We will investigate.

P.S. Moved to Premium Help.

michaeld
Jun 09, 2013, 10:27 PM
Do you allow community updates to the ext.net codebase?

Daniil
Jun 10, 2013, 3:43 AM
Do you allow community updates to the ext.net codebase?

I think we don't. We will think about it. Thank you for the question.

Created an Issue.
https://github.com/extnet/Ext.NET/issues/272


I do want to do some more performance fixes because I see a lot of opportunity for improvement. My website is going online this month and it's going to be very public in the US, so performance and scalability will be a topic in the months ahead. I'd like to contribute but I understand you guys probably have a test process that I would not otherwise have access to. We could consider a branch or I can just submit my changes as I did above. Let me know what's best. First pass will continue to be uncomplicated, easy to verify code-reviewable changes.

Currently, the best option for us if you create an individual forum thread for each improvement (or a set of tightly related improvements). Actually, as you did in this thread.

michaeld
Jun 10, 2013, 10:14 PM
Anyway, the code above got committed so you can close this item. Thank you.

I do want to do some more performance fixes because I see a lot of opportunity for improvement. My website is going online this month and it's going to be very public in the US, so performance and scalability will be a topic in the months ahead. I'd like to contribute but I understand you guys probably have a test process that I would not otherwise have access to. We could consider a branch or I can just submit my changes as I did above. Let me know what's best. First pass will continue to be uncomplicated, easy to verify code-reviewable changes.