diff --git a/SharpBenchmark.AssemblyHelper/ActionHelper.cs b/SharpBenchmark.AssemblyHelper/ActionHelper.cs new file mode 100644 index 0000000..8586016 --- /dev/null +++ b/SharpBenchmark.AssemblyHelper/ActionHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Reflection; + +namespace SharpBenchmark.AssemblyHelper +{ + public static class ActionHelper + { + public static Action BuildTestAction(Type instanceType, MethodInfo method, object[] parameterValues) + { + // this has parameters + var delegateMethod = CreateDelegateWithParameters(instanceType, method); + + // build the action to return + return () => delegateMethod.DynamicInvoke(parameterValues); + } + + private static Delegate CreateDelegateWithParameters(Type instanceType, MethodInfo method) + { + + object instance = null; + + if (!method.IsStatic) + { + //var constructors = instanceType.GetConstructors(); + + instance = Activator.CreateInstance(instanceType); + } + + var parameters = method.GetParameters(); + var args = new Expression[parameters.Length]; + var parameterExpressions = new List(); + for (var i = 0; i < args.Length; i++) + { + args[i] = Expression.Parameter(parameters[i].ParameterType, parameters[i].Name); + parameterExpressions.Add((ParameterExpression)args[i]); + } + + var callExpression = Expression.Call(instance == null ? null : Expression.Constant(instance), method, args); + + var lambdaExpression = Expression.Lambda(callExpression, parameterExpressions); + + return lambdaExpression.Compile(); + } + } +} diff --git a/SharpBenchmark.AssemblyHelper/Properties/AssemblyInfo.cs b/SharpBenchmark.AssemblyHelper/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c5d9e4f --- /dev/null +++ b/SharpBenchmark.AssemblyHelper/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SharpBenchmark.AssemblyHelper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SharpBenchmark.AssemblyHelper")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bdafd678-59fb-40d7-affa-80d41c09ff99")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SharpBenchmark.AssemblyHelper/SharpBenchmark.AssemblyHelper.csproj b/SharpBenchmark.AssemblyHelper/SharpBenchmark.AssemblyHelper.csproj new file mode 100644 index 0000000..f52c0cb --- /dev/null +++ b/SharpBenchmark.AssemblyHelper/SharpBenchmark.AssemblyHelper.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {F6E26086-C663-43BE-A893-E9B6C5F6894A} + Library + Properties + SharpBenchmark.AssemblyHelper + SharpBenchmark.AssemblyHelper + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpBenchmark.ExampleDll/ConstrucutorNeedsParams.cs b/SharpBenchmark.ExampleDll/ConstrucutorNeedsParams.cs new file mode 100644 index 0000000..17d4c3f --- /dev/null +++ b/SharpBenchmark.ExampleDll/ConstrucutorNeedsParams.cs @@ -0,0 +1,23 @@ +using System.Threading; + +namespace SharpBenchmark.ExampleDll +{ + public class ConstrucutorNeedsParams + { + private readonly int _delay; + public ConstrucutorNeedsParams(int delay) + { + _delay = delay; + } + + public void Algorithm1() + { + Thread.Sleep(_delay); + } + + public void Algorithm2(string name) + { + Thread.Sleep(_delay); + } + } +} diff --git a/SharpBenchmark.ExampleDll/Properties/AssemblyInfo.cs b/SharpBenchmark.ExampleDll/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a416839 --- /dev/null +++ b/SharpBenchmark.ExampleDll/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SharpBenchmark.ExampleDll")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SharpBenchmark.ExampleDll")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6b46f92e-0bdc-4208-b4a0-7ad34ad2d567")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SharpBenchmark.ExampleDll/SharpBenchmark.ExampleDll.csproj b/SharpBenchmark.ExampleDll/SharpBenchmark.ExampleDll.csproj new file mode 100644 index 0000000..8cd768b --- /dev/null +++ b/SharpBenchmark.ExampleDll/SharpBenchmark.ExampleDll.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {0ACEB135-2314-4A6F-A9B6-3D2EF5B013B9} + Library + Properties + SharpBenchmark.ExampleDll + SharpBenchmark.ExampleDll + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpBenchmark.ExampleDll/Test1.cs b/SharpBenchmark.ExampleDll/Test1.cs new file mode 100644 index 0000000..880f994 --- /dev/null +++ b/SharpBenchmark.ExampleDll/Test1.cs @@ -0,0 +1,22 @@ +using System.Threading; + +namespace SharpBenchmark.ExampleDll +{ + public class Test1 + { + public void Algorithm1() + { + Thread.Sleep(125); + } + + public void Algorithm2() + { + Thread.Sleep(235); + } + + public static void StaticAlgorithm() + { + Thread.Sleep(750); + } + } +} diff --git a/SharpBenchmark.ExampleDll/Test2.cs b/SharpBenchmark.ExampleDll/Test2.cs new file mode 100644 index 0000000..305519e --- /dev/null +++ b/SharpBenchmark.ExampleDll/Test2.cs @@ -0,0 +1,22 @@ +using System.Threading; + +namespace SharpBenchmark.ExampleDll +{ + public class Test2 + { + public void Algorithm1(int delay) + { + Thread.Sleep(delay); + } + + public void Algorithm2(int delay) + { + Thread.Sleep(delay); + } + + public static void StaticAlgorithm(int delay) + { + Thread.Sleep(delay); + } + } +} \ No newline at end of file diff --git a/SharpBenchmark.ExampleDll/Test3.cs b/SharpBenchmark.ExampleDll/Test3.cs new file mode 100644 index 0000000..e729d63 --- /dev/null +++ b/SharpBenchmark.ExampleDll/Test3.cs @@ -0,0 +1,28 @@ +using System; +using System.Threading; + +namespace SharpBenchmark.ExampleDll +{ + public class Test3 + { + public void Algorithm1(int delay, string name, DateTime date) + { + Thread.Sleep(delay); + } + + public void Algorithm2(int delay, string name, bool isSomething) + { + Thread.Sleep(delay); + } + + public void Algorithm3(int delay, decimal price) + { + Thread.Sleep(delay); + } + + public static void StaticAlgorithm(int delay, string name, bool isSomething) + { + Thread.Sleep(delay); + } + } +} diff --git a/SharpBenchmark.ExampleDll/TestStatic.cs b/SharpBenchmark.ExampleDll/TestStatic.cs new file mode 100644 index 0000000..6923f0e --- /dev/null +++ b/SharpBenchmark.ExampleDll/TestStatic.cs @@ -0,0 +1,12 @@ +using System.Threading; + +namespace SharpBenchmark.ExampleDll +{ + public static class TestStatic + { + public static void StaticAlgorithm(int delay, string name, bool isSomething) + { + Thread.Sleep(delay); + } + } +} diff --git a/SharpBenchmark.Samples/App.config b/SharpBenchmark.Samples/App.config index 8e15646..6f59ab1 100644 --- a/SharpBenchmark.Samples/App.config +++ b/SharpBenchmark.Samples/App.config @@ -3,4 +3,7 @@ + + + \ No newline at end of file diff --git a/SharpBenchmark.Samples/Code/Sample2.cs b/SharpBenchmark.Samples/Code/Sample2.cs index 43158c7..2bcb956 100644 --- a/SharpBenchmark.Samples/Code/Sample2.cs +++ b/SharpBenchmark.Samples/Code/Sample2.cs @@ -1,6 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; + namespace SharpBenchmark.Samples.Code { class Sample2 : Sample @@ -13,7 +12,7 @@ public override void Execute(string[] args) AddTest("Activator.CreateInstance()", () => ActivatorCreateInstanceGeneric()); AddTest("Activator.CreateInstance(type)", () => ActivatorCreateInstanceType(typeof (TestClass))); - RunTests(0, 10); + RunTests(TimeSpan.FromSeconds(10)); } private static TestClass NewTestClass() diff --git a/SharpBenchmark.Samples/DelegateBuilder.cs b/SharpBenchmark.Samples/DelegateBuilder.cs new file mode 100644 index 0000000..26c0079 --- /dev/null +++ b/SharpBenchmark.Samples/DelegateBuilder.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; + +namespace SharpBenchmark.Samples +{ + public class DelegateBuilder + { + public static T BuildDelegate(MethodInfo method, params object[] missingParamValues) + { + var queueMissingParams = new Queue(missingParamValues); + + var dgtMi = typeof(T).GetMethod("Invoke"); + var dgtRet = dgtMi.ReturnType; + var dgtParams = dgtMi.GetParameters(); + + var paramsOfDelegate = dgtParams + .Select(tp => Expression.Parameter(tp.ParameterType, tp.Name)) + .ToArray(); + + var methodParams = method.GetParameters(); + + if (method.IsStatic) + { + var paramsToPass = methodParams + .Select((p, i) => CreateParam(paramsOfDelegate, i, p, queueMissingParams)) + .ToArray(); + + var expr = Expression.Lambda( + Expression.Call(method, paramsToPass), + paramsOfDelegate); + + return expr.Compile(); + } + else + { + var paramThis = Expression.Convert(paramsOfDelegate[0], method.DeclaringType); + + var paramsToPass = methodParams + .Select((p, i) => CreateParam(paramsOfDelegate, i + 1, p, queueMissingParams)) + .ToArray(); + + var expr = Expression.Lambda( + Expression.Call(paramThis, method, paramsToPass), + paramsOfDelegate); + + return expr.Compile(); + } + } + + private static Expression CreateParam(ParameterExpression[] paramsOfDelegate, int i, ParameterInfo callParamType, Queue queueMissingParams) + { + if (i < paramsOfDelegate.Length) + return Expression.Convert(paramsOfDelegate[i], callParamType.ParameterType); + + if (queueMissingParams.Count > 0) + return Expression.Constant(queueMissingParams.Dequeue()); + + if (callParamType.ParameterType.IsValueType) + return Expression.Constant(Activator.CreateInstance(callParamType.ParameterType)); + + return Expression.Constant(null); + } + } +} diff --git a/SharpBenchmark.Samples/Program.cs b/SharpBenchmark.Samples/Program.cs index 74468c1..4d2ae54 100644 --- a/SharpBenchmark.Samples/Program.cs +++ b/SharpBenchmark.Samples/Program.cs @@ -1,5 +1,8 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Reflection; +using SharpBenchmark.AssemblyHelper; namespace SharpBenchmark.Samples { @@ -11,12 +14,18 @@ static void Main(string[] args) while (true) { - Console.Write("Which sample would you like to run? (enter q to quit): "); + Console.Write("Which sample would you like to run? (enter q to quit, enter dll to load a dll): "); var input = Console.ReadLine(); if (input == "q" || input == null) break; + if (input == "dll") + { + LoadDll(); + continue; + } + var parts = input.Split(' '); var sampleNum = 0; if (!Int32.TryParse(parts[0], out sampleNum)) @@ -42,5 +51,92 @@ static void Main(string[] args) sample.Execute(tmp.ToArray()); } } + + static void LoadDll() + { + Console.WriteLine("Full Path to DLL (or blank to use testing DLL): "); + var path = Console.ReadLine(); + //Console.WriteLine("Full Path to DLL: "); + if (String.IsNullOrEmpty(path)) + path = @"C:\Projects\SharpBenchmark\SharpBenchmark.ExampleDll\bin\Debug\SharpBenchmark.ExampleDll.dll"; + + if (String.IsNullOrEmpty(path)) return; + + var dll = Assembly.LoadFrom(path); + var types = dll.GetTypes(); + + Console.WriteLine("Types in the DLL"); + Console.WriteLine("-------------------------"); + + var i = 1; + foreach (var type in types) + { + Console.WriteLine("{0}) {1} ", i, type.FullName); + + i++; + } + + Console.WriteLine(); + Console.WriteLine("Enter the number of the type you'd like to use: "); + var input = Console.ReadLine(); + + var typeNum = Int32.Parse(input); + var selectedType = types[typeNum - 1]; + + Console.WriteLine(); + Console.WriteLine("Methods in this type"); + Console.WriteLine("-------------------------"); + + // get all public methods + i = 1; + var methods = selectedType.GetMethods(BindingFlags.DeclaredOnly); + foreach (var method in methods) + { + Console.Write("{0}) {1}(", i, method.Name); + + var piNum = 1; + foreach (var pi in method.GetParameters()) + { + Console.Write("{0}{1} {2}", piNum != 1 ? "," : "", pi.ParameterType, pi.Name); + piNum++; + } + + Console.WriteLine(")"); + i++; + } + + Console.WriteLine(); + Console.Write("Enter the number(s) of the methods you'd like to use (comma separated): "); + input = Console.ReadLine(); + Console.WriteLine(); + + var benchmarker = new Benchmarker(); + + foreach (var methodNum in input.Split(',').Select(x => Int32.Parse(x.Trim()))) + { + var selectedMethod = methods[methodNum - 1]; + + var parameters = selectedMethod.GetParameters(); + + var paramValues = new List(); + foreach (var parameter in parameters) + { + Console.Write(" Enter a value for the parameter {0} {1}: ", parameter.ParameterType, parameter.Name); + var paramInput = Console.ReadLine(); + Console.WriteLine(); + + paramValues.Add(Convert.ChangeType(paramInput, parameter.ParameterType)); + } + + // call the delegate from my action with the proper parameters + benchmarker.AddTest(selectedMethod.Name, ActionHelper.BuildTestAction(selectedType, selectedMethod, paramValues.ToArray())); + } + + //benchmarker.AddTest("Hard-coded", () => new Test3().Algorithm2(125, "Test", true)); + + benchmarker.RunTests(20); + } + + } } diff --git a/SharpBenchmark.Samples/SharpBenchmark.Samples.csproj b/SharpBenchmark.Samples/SharpBenchmark.Samples.csproj index d01e281..3df50eb 100644 --- a/SharpBenchmark.Samples/SharpBenchmark.Samples.csproj +++ b/SharpBenchmark.Samples/SharpBenchmark.Samples.csproj @@ -33,6 +33,7 @@ + @@ -42,6 +43,7 @@ + @@ -52,6 +54,10 @@ + + {f6e26086-c663-43be-a893-e9b6c5f6894a} + SharpBenchmark.AssemblyHelper + {df0fc087-3d83-4dd4-b8f9-f6688f5fc70a} SharpBenchmark diff --git a/SharpBenchmark.Wpf/App.config b/SharpBenchmark.Wpf/App.config new file mode 100644 index 0000000..17e3efc --- /dev/null +++ b/SharpBenchmark.Wpf/App.config @@ -0,0 +1,33 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SharpBenchmark.Wpf/App.xaml b/SharpBenchmark.Wpf/App.xaml new file mode 100644 index 0000000..8d8741d --- /dev/null +++ b/SharpBenchmark.Wpf/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/SharpBenchmark.Wpf/App.xaml.cs b/SharpBenchmark.Wpf/App.xaml.cs new file mode 100644 index 0000000..5648bfe --- /dev/null +++ b/SharpBenchmark.Wpf/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace SharpBenchmark.Wpf +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/SharpBenchmark.Wpf/AppBootstrapper.cs b/SharpBenchmark.Wpf/AppBootstrapper.cs new file mode 100644 index 0000000..66d451b --- /dev/null +++ b/SharpBenchmark.Wpf/AppBootstrapper.cs @@ -0,0 +1,40 @@ +using System; +using System.ComponentModel.Composition; +using System.ComponentModel.Composition.Hosting; +using System.ComponentModel.Composition.Primitives; +using System.Linq; +using Caliburn.Micro; + +namespace SharpBenchmark.Wpf +{ + public class AppBootstrapper : Bootstrapper + { + private CompositionContainer container; + + protected override void Configure() + { + container = new CompositionContainer(new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType())); + + CompositionBatch batch = new CompositionBatch(); + + batch.AddExportedValue(new WindowManager()); + batch.AddExportedValue(new EventAggregator()); + batch.AddExportedValue(container); + + container.Compose(batch); + } + + protected override object GetInstance(Type serviceType, string key) + { + string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key; + var exports = container.GetExportedValues(contract); + + if (exports.Count() > 0) + { + return exports.First(); + } + + throw new Exception(string.Format("Could not locate any instances of contract {0}.", contract)); + } + } +} \ No newline at end of file diff --git a/SharpBenchmark.Wpf/Caliburn/Micro/Logging/DebugLogger.cs b/SharpBenchmark.Wpf/Caliburn/Micro/Logging/DebugLogger.cs new file mode 100644 index 0000000..647c748 --- /dev/null +++ b/SharpBenchmark.Wpf/Caliburn/Micro/Logging/DebugLogger.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; + +// ReSharper disable CheckNamespace +namespace Caliburn.Micro.Logging +// ReSharper restore CheckNamespace +{ + /// + /// Implementation of the ILog and ILogExtended interfaces using + /// . + /// + public class DebugLogger : ILog, ILogExtended + { + #region Constants + private const string ErrorText = "ERROR"; + private const string WarnText = "WARN"; + private const string InfoText = "INFO"; + #endregion + + #region Fields + private readonly Type _type; + #endregion + + #region Constructors + public DebugLogger(Type type) + { + _type = type; + } + #endregion + + #region Helper Methods + private string CreateLogMessage(string format, params object[] args) + { + return string.Format("[{0}] {1}", DateTime.Now.ToString("o"), string.Format(format, args)); + } + #endregion + + #region ILog Members + /// + /// Logs the exception. + /// + /// The exception. + public void Error(Exception exception) + { + Debug.WriteLine(CreateLogMessage(exception.ToString()), ErrorText); + } + /// + /// Logs the message as info. + /// + /// A formatted message.Parameters to be injected into the formatted message. + public void Info(string format, params object[] args) + { + Debug.WriteLine(CreateLogMessage(format, args), InfoText); + } + /// + /// Logs the message as a warning. + /// + /// A formatted message.Parameters to be injected into the formatted message. + public void Warn(string format, params object[] args) + { + Debug.WriteLine(CreateLogMessage(format, args), WarnText); + } + #endregion + + #region Implementation of ILogExtended + /// + /// Logs the message as error. + /// + /// A formatted message. + /// Parameters to be injected into the formatted message. + public void Error(string format, params object[] args) + { + Debug.WriteLine(CreateLogMessage(format, args), ErrorText); + } + /// + /// Logs the exception. + /// + /// The exception. + /// A formatted message. + /// Parameters to be injected into the formatted message. + public void Error(Exception exception, string format, params object[] args) + { + Debug.WriteLine(CreateLogMessage(format + " - Exception = " + exception.ToString(), args), ErrorText); + } + #endregion + } +} diff --git a/SharpBenchmark.Wpf/IShell.cs b/SharpBenchmark.Wpf/IShell.cs new file mode 100644 index 0000000..9c0bbd8 --- /dev/null +++ b/SharpBenchmark.Wpf/IShell.cs @@ -0,0 +1,3 @@ +namespace SharpBenchmark.Wpf { + public interface IShell {} +} \ No newline at end of file diff --git a/SharpBenchmark.Wpf/Models/AssemblyExplorerItem.cs b/SharpBenchmark.Wpf/Models/AssemblyExplorerItem.cs new file mode 100644 index 0000000..d5231d4 --- /dev/null +++ b/SharpBenchmark.Wpf/Models/AssemblyExplorerItem.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace SharpBenchmark.Wpf.Models +{ + public class AssemblyExplorerItem + { + public AssemblyExplorerItem(string path) + { + var dll = Assembly.LoadFrom(path); + + Name = dll.FullName; + Classes = dll.GetTypes().Select(x => new ClassItem(x)).ToList(); + } + + public string Name { get; set; } + public IList Classes { get; set; } + + // for the tree view + public IList Children { get { return Classes; } } + public string Display + { + get { return Name; } + } + + public class ClassItem + { + public ClassItem(Type type) + { + Type = type; + Name = type.FullName; + + Constructors = type.GetConstructors().Select(x => new ConstructorItem(x)).ToList() ; + + Methods = type.GetMethods().Where(x => x.DeclaringType != typeof(object)).Select(x => new MethodItem(Type, x)).ToList(); + } + + public string Name { get; set; } + public Type Type { get; set; } + + public IList Constructors { get; set; } + public IList Methods { get; set; } + + // for tree view + public IList Children { get { return Methods; } } + public string Display + { + get { return Name; } + } + } + + public class MethodItem + { + public MethodItem(Type instanceType, MethodInfo methodInfo) + { + MethodInfo = methodInfo; + InstanceType = instanceType; + Name = MethodInfo.Name; + + Parameters = MethodInfo.GetParameters().Select(x => new ParameterItem(x)).ToList(); + } + + public MethodInfo MethodInfo { get; set; } + public Type InstanceType { get; set; } + public string Name { get; set; } + + public IList Parameters { get; set; } + + // for tree view + //public IList Children { get { return Methods; } } + public string Display + { + get + { + var parameters = String.Join(",", Parameters.Select(x => String.Format("{0} {1}", x.TypeName, x.Name))); + + return String.Format("{0}({1})", Name, parameters); + } + } + } + + public class ConstructorItem + { + private readonly ConstructorInfo _constructorInfo; + + public ConstructorItem(ConstructorInfo constructorInfo) + { + _constructorInfo = constructorInfo; + + Parameters = _constructorInfo.GetParameters().Select(x => new ParameterItem(x)).ToList(); + } + + public IList Parameters { get; set; } + } + + public class ParameterItem + { + public ParameterItem(ParameterInfo parameterInfo) + { + Name = parameterInfo.Name; + Type = parameterInfo.ParameterType; + TypeName = Type.Name; + } + + public string Name { get; set; } + public Type Type { get; set; } + public string TypeName { get; set; } + + public string InputValue { get; set; } + } + } +} diff --git a/SharpBenchmark.Wpf/Models/AssemblyFilePath.cs b/SharpBenchmark.Wpf/Models/AssemblyFilePath.cs new file mode 100644 index 0000000..030473f --- /dev/null +++ b/SharpBenchmark.Wpf/Models/AssemblyFilePath.cs @@ -0,0 +1,10 @@ +using System; + +namespace SharpBenchmark.Wpf.Models +{ + public class AssemblyFilePath + { + public Guid AssemblyFilePathId { get; set; } + public string Path { get; set; } + } +} diff --git a/SharpBenchmark.Wpf/Properties/AssemblyInfo.cs b/SharpBenchmark.Wpf/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..20ac2ed --- /dev/null +++ b/SharpBenchmark.Wpf/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SharpBenchmark.Wpf")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SharpBenchmark.Wpf")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SharpBenchmark.Wpf/Properties/Resources.Designer.cs b/SharpBenchmark.Wpf/Properties/Resources.Designer.cs new file mode 100644 index 0000000..56540b3 --- /dev/null +++ b/SharpBenchmark.Wpf/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18047 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SharpBenchmark.Wpf.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpBenchmark.Wpf.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/SharpBenchmark.Wpf/Properties/Resources.resx b/SharpBenchmark.Wpf/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/SharpBenchmark.Wpf/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SharpBenchmark.Wpf/Properties/Settings.Designer.cs b/SharpBenchmark.Wpf/Properties/Settings.Designer.cs new file mode 100644 index 0000000..7fbc225 --- /dev/null +++ b/SharpBenchmark.Wpf/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18047 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SharpBenchmark.Wpf.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/SharpBenchmark.Wpf/Properties/Settings.settings b/SharpBenchmark.Wpf/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/SharpBenchmark.Wpf/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/SharpBenchmark.Wpf/Repositories.cs b/SharpBenchmark.Wpf/Repositories.cs new file mode 100644 index 0000000..199511d --- /dev/null +++ b/SharpBenchmark.Wpf/Repositories.cs @@ -0,0 +1,12 @@ +using System; +using SharpBenchmark.Wpf.Models; +using SharpRepository.Repository; + +namespace SharpBenchmark.Wpf +{ + public static class Repositories + { + public static IRepository AssemblyFileRepository = RepositoryFactory.GetInstance(); +// public static IRepository AssemblyFileRepository = RepositoryFactory.GetInstance(); + } +} diff --git a/SharpBenchmark.Wpf/ResultsView.xaml b/SharpBenchmark.Wpf/ResultsView.xaml new file mode 100644 index 0000000..0adfbff --- /dev/null +++ b/SharpBenchmark.Wpf/ResultsView.xaml @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/SharpBenchmark.Wpf/ResultsViewModel.cs b/SharpBenchmark.Wpf/ResultsViewModel.cs new file mode 100644 index 0000000..ab46468 --- /dev/null +++ b/SharpBenchmark.Wpf/ResultsViewModel.cs @@ -0,0 +1,12 @@ +namespace SharpBenchmark.Wpf +{ + public class ResultsViewModel + { + public ResultsViewModel(string results) + { + Display = results; + } + + public string Display { get; set; } + } +} diff --git a/SharpBenchmark.Wpf/SharpBenchmark.Wpf.csproj b/SharpBenchmark.Wpf/SharpBenchmark.Wpf.csproj new file mode 100644 index 0000000..853aa5a --- /dev/null +++ b/SharpBenchmark.Wpf/SharpBenchmark.Wpf.csproj @@ -0,0 +1,159 @@ + + + + + Debug + AnyCPU + {23DD0E1F-D1D8-4E6B-930E-C92D78BA6754} + WinExe + Properties + SharpBenchmark.Wpf + SharpBenchmark.Wpf + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + False + ..\packages\Caliburn.Micro.1.5.2\lib\net45\Caliburn.Micro.dll + + + ..\packages\Caliburn.Micro.Logging.1.5.0.0\lib\net40\Caliburn.Micro.Logging.dll + + + ..\packages\Caliburn.Micro.Logging.NLog.1.5.0.0\lib\net40\Caliburn.Micro.Logging.NLog.dll + + + ..\packages\NLog.2.0.1.2\lib\net45\NLog.dll + + + + + False + ..\packages\SharpRepository.Repository.1.3.6.0\lib\net40\SharpRepository.Repository.dll + + + False + ..\packages\SharpRepository.XmlRepository.1.3.5.18-unstable\lib\net40\SharpRepository.XmlRepository.dll + + + + + + + + ..\packages\Caliburn.Micro.1.5.2\lib\net45\System.Windows.Interactivity.dll + + + + + + + + 4.0 + + + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + App.xaml + Code + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + {f6e26086-c663-43be-a893-e9b6c5f6894a} + SharpBenchmark.AssemblyHelper + + + {df0fc087-3d83-4dd4-b8f9-f6688f5fc70a} + SharpBenchmark + + + + + \ No newline at end of file diff --git a/SharpBenchmark.Wpf/ShellView.xaml b/SharpBenchmark.Wpf/ShellView.xaml new file mode 100644 index 0000000..b619626 --- /dev/null +++ b/SharpBenchmark.Wpf/ShellView.xaml @@ -0,0 +1,77 @@ + + + + + + + + + +