- nperf_src.zip
- Releases
- Unpackaged
- nperf-1.1-Release
- nperf
- src
- nperf_demo.zip
- bin
- Release
- NPerf.Cons.exe
- NPerf.Core.dll
- NPerf.Framework.dll
- NPerf.Report.dll
- nperf-doc-1.1.chm
- scpl.dll
- System.Perf.dll
- nperf_bin.zip
- Release
- NPerf.Cons.exe
- NPerf.Core.dll
- NPerf.Framework.chm
- NPerf.Framework.dll
- NPerf.Report.dll
- scpl.dll
- system.perf.bat
- System.Perf.dll
|
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace System.Perf
{
using System;
using System.Text;
using System.IO;
using NPerf.Framework;
public interface IStringRunner
{
void Concat(string s);
void ConcatFormat(string format, params string[] s);
}
public class StringWriterRunner : IStringRunner
{
private StringWriter sw;
public StringWriterRunner()
{
this.sw = new StringWriter();
}
public void Concat(string s)
{
sw.Write(s);
}
public void ConcatFormat(string format, params string[] s)
{
sw.Write(format,s);
}
}
public class StringBuilderRunner : IStringRunner
{
private StringBuilder sb;
public StringBuilderRunner()
{
this.sb = new StringBuilder();
}
public void Concat(string s)
{
sb.Append(s);
}
public void ConcatFormat(string format, params string[] s)
{
sb.AppendFormat(format,s);
}
}
public class StringRunner : IStringRunner
{
private String sb;
public StringRunner()
{
this.sb = "";
}
public void Concat(string s)
{
sb+=s;
}
public void ConcatFormat(string format, params string[] s)
{
sb+=String.Format(format,s);
}
}
[PerfTester(typeof(IStringRunner),13
,Description = "Testing build construction"
,FeatureDescription="Number of concatenations")]
public class StringBuildingTester
{
private int count;
private Random rnd = new Random();
internal int CollectionCount(int testIndex)
{
int n = 0;
if (testIndex < 0)
n=3;
else
n = (int)Math.Pow(2,testIndex);
return n;
}
[PerfRunDescriptor]
public double RunDescription(int testIndex)
{
return (double)CollectionCount(testIndex);
}
[PerfSetUp]
public void SetUp(int index, IStringRunner dic)
{
this.count = CollectionCount(index);
}
[PerfTest]
public void Concat(IStringRunner sr)
{
string s = "myword";
for(int i = 0;i<count;++i)
sr.Concat(s);
}
[PerfTest]
public void ConcatFormat(IStringRunner sr)
{
string format="{0} {1}";
string s1 = "myword";
string s2 = "myotherword";
for(int i = 0;i<count;++i)
sr.ConcatFormat(format,s1,s2);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).