Skip to content

Commit

Permalink
Use spaces for indentation, as discussed in #143.
Browse files Browse the repository at this point in the history
This should make it easier for everyone who wishes to contribute, since it seems that most people prefer to use spaces.
  • Loading branch information
antoine-aubry committed Feb 1, 2016
1 parent 4b974f6 commit 2b78ca8
Show file tree
Hide file tree
Showing 197 changed files with 17,109 additions and 17,108 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Attempt to follow the [SOLID](https://en.wikipedia.org/wiki/SOLID_%28object-orie

As long as you keep the code readable, I don't care too much about any specific coding convention. There are only a few rules that should be honored:

* Use **tabs** instead of spaces. The entire code base is tab-indented, and there's no value in changing.
* Use **4 spaces** to indent.
* Each class / interface / struct / delegate **goes to its own file**.
* The only acceptable exception is for small and closely related types.
* Use sane indentation rules. Break long lines when needed, but don't be obsessive:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

namespace YamlDotNet.PerformanceTests.Lib
{
public interface ISerializationTest
{
object Graph { get; }
}
public interface ISerializationTest
{
object Graph { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

namespace YamlDotNet.PerformanceTests.Lib
{
public interface ISerializerAdapter
{
void Serialize (TextWriter writer, object graph);
}
public interface ISerializerAdapter
{
void Serialize (TextWriter writer, object graph);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,52 @@

namespace YamlDotNet.PerformanceTests.Lib
{
public class PerformanceTestRunner
{
private const int _defaultIterations = 10000;
public class PerformanceTestRunner
{
private const int _defaultIterations = 10000;

public void Run(ISerializerAdapter serializer, string[] args)
{
var iterations = args.Length > 0
? int.Parse(args[0])
: _defaultIterations;
public void Run(ISerializerAdapter serializer, string[] args)
{
var iterations = args.Length > 0
? int.Parse(args[0])
: _defaultIterations;

var adapterName = serializer.GetType().Namespace.Split('.').Last();
var adapterName = serializer.GetType().Namespace.Split('.').Last();

var tests = typeof(ISerializationTest).Assembly
.GetTypes()
.Where(t => t.IsClass && typeof(ISerializationTest).IsAssignableFrom(t))
.Select(t => (ISerializationTest)Activator.CreateInstance(t));
var tests = typeof(ISerializationTest).Assembly
.GetTypes()
.Where(t => t.IsClass && typeof(ISerializationTest).IsAssignableFrom(t))
.Select(t => (ISerializationTest)Activator.CreateInstance(t));

foreach(var test in tests)
{
Console.Write("{0}\t{1}\t", adapterName, test.GetType().Name);
foreach(var test in tests)
{
Console.Write("{0}\t{1}\t", adapterName, test.GetType().Name);

var graph = test.Graph;
var graph = test.Graph;

// Warmup
RunTest(serializer, graph);
// Warmup
RunTest(serializer, graph);

if(!Stopwatch.IsHighResolution)
{
Console.Error.WriteLine("Stopwatch is not high resolution!");
}
if(!Stopwatch.IsHighResolution)
{
Console.Error.WriteLine("Stopwatch is not high resolution!");
}

var timer = Stopwatch.StartNew();
for (var i = 0; i < iterations; ++i)
{
RunTest(serializer, graph);
}
var duration = timer.Elapsed;
Console.WriteLine("{0}", duration.TotalMilliseconds / iterations);
}
}
var timer = Stopwatch.StartNew();
for (var i = 0; i < iterations; ++i)
{
RunTest(serializer, graph);
}
var duration = timer.Elapsed;
Console.WriteLine("{0}", duration.TotalMilliseconds / iterations);
}
}

private void RunTest(ISerializerAdapter serializer, object graph)
{
var buffer = new StringWriter();
serializer.Serialize(buffer, graph);
}
}
private void RunTest(ISerializerAdapter serializer, object graph)
{
var buffer = new StringWriter();
serializer.Serialize(buffer, graph);
}
}
}

94 changes: 47 additions & 47 deletions PerformanceTests/YamlDotNet.PerformanceTests.Lib/Tests/Receipt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,54 @@

namespace YamlDotNet.PerformanceTests.Lib
{
public class Receipt : ISerializationTest
{
public object Graph {
get {
var address = new
{
street = "123 Tornado Alley\nSuite 16",
city = "East Westville",
state = "KS"
};
public class Receipt : ISerializationTest
{
public object Graph {
get {
var address = new
{
street = "123 Tornado Alley\nSuite 16",
city = "East Westville",
state = "KS"
};

var receipt = new
{
receipt = "Oz-Ware Purchase Invoice",
date = new DateTime(2007, 8, 6),
customer = new
{
given = "Dorothy",
family = "Gale"
},
items = new[]
{
new
{
part_no = "A4786",
descrip = "Water Bucket (Filled)",
price = 1.47M,
quantity = 4
},
new
{
part_no = "E1628",
descrip = "High Heeled \"Ruby\" Slippers",
price = 100.27M,
quantity = 1
}
},
bill_to = address,
ship_to = address,
specialDelivery = "Follow the Yellow Brick\n" +
"Road to the Emerald City.\n" +
"Pay no attention to the\n" +
"man behind the curtain."
};
var receipt = new
{
receipt = "Oz-Ware Purchase Invoice",
date = new DateTime(2007, 8, 6),
customer = new
{
given = "Dorothy",
family = "Gale"
},
items = new[]
{
new
{
part_no = "A4786",
descrip = "Water Bucket (Filled)",
price = 1.47M,
quantity = 4
},
new
{
part_no = "E1628",
descrip = "High Heeled \"Ruby\" Slippers",
price = 100.27M,
quantity = 1
}
},
bill_to = address,
ship_to = address,
specialDelivery = "Follow the Yellow Brick\n" +
"Road to the Emerald City.\n" +
"Pay no attention to the\n" +
"man behind the curtain."
};

return receipt;
}
}
}
return receipt;
}
}
}
}

Loading

0 comments on commit 2b78ca8

Please sign in to comment.