Skip to content

Instantly share code, notes, and snippets.

[Serializable]
[DataContract]
public class Test {
[DataMember(Order = 1)]
public int ID { get; set; }
[DataMember(Order = 2)]
public string Text { get; set; }
[DataMember(Order = 3)]
public Complex Inner { get; set; }
}
@rpgmaker
rpgmaker / gist:c04ceee9a2cdddc0458a
Created September 6, 2014 19:59
Test Performance of NetJSON Long to String in comparision to ToString(CultureInfo)
static void Test(string name, Action action) {
var count = 10000;
var stopWatch = new Stopwatch();
stopWatch.Start();
for (var i = 0; i < count; i++)
action();
stopWatch.Stop();
Console.WriteLine("Iteration: {0}", count);
Console.WriteLine("Completed {0} in Avg {1} Milliseconds", name, stopWatch.ElapsedMilliseconds);
Console.WriteLine();
@rpgmaker
rpgmaker / gist:34b8dfd5b7b4617af6f4
Created July 24, 2014 23:25
Performance Comparison JSON vs Binary (Serialization only)
Completed Phoenix Json in Avg 55 Milliseconds
-----------------------------------
Completed MessageShark in Avg 56 Milliseconds
-----------------------------------
Completed ProtoBuf in Avg 65 Milliseconds
-----------------------------------
Completed ObjectSerialization in Avg 110 Milliseconds
-----------------------------------
Completed Service Stack Json in Avg 192 Milliseconds
-----------------------------------
@rpgmaker
rpgmaker / gist:0a91d5b6c5dba488e8f1
Last active August 29, 2015 14:04
Performance comparison JSON vs Binary (Serialization and Deserialization)
Completed MessageShark in Avg 117 Milliseconds
-----------------------------------
Completed Phoenix Json in Avg 144 Milliseconds
-----------------------------------
Completed ProtoBuf in Avg 166 Milliseconds
-----------------------------------
Completed ObjectSerialization in Avg 210 Milliseconds
-----------------------------------
Completed fastJSON in Avg 383 Milliseconds
-----------------------------------
@rpgmaker
rpgmaker / gist:7611322
Created November 23, 2013 05:58
Performance Comparison for complex object 600k iteration each
Completed Phoenix Json in Avg 436 Milliseconds
Completed MessageShark in Avg 482 Milliseconds
Completed ProtoBuf in Avg 509 Milliseconds
Completed Phoenix Xml in Avg 1272 Milliseconds
Completed Service Stack Json in Avg 1792 Milliseconds
Completed Newton JSON.NET in Avg 2542 Milliseconds
Completed fastJSON in Avg 3296 Milliseconds
Completed MessagePack in Avg 5601 Milliseconds
Press any key to continue . . .
@rpgmaker
rpgmaker / gist:7576829
Last active December 28, 2015 23:09
C++ join characters logic
static char[][] join(string text, int size = 4) {
return new char[][] { ("0" + text).ToJoinArray(size), ("1" + text).ToJoinArray(size), ("2" + text).ToJoinArray(size),
("3" + text).ToJoinArray(size),
("4" + text).ToJoinArray(size),
("5" + text).ToJoinArray(size),
("6" + text).ToJoinArray(size), ("7" + text).ToJoinArray(size),
("8" + text).ToJoinArray(size), ("9" + text).ToJoinArray(size) };
}
static char[][] join2(string text, int size = 4) {
@rpgmaker
rpgmaker / JSON.NET Json
Created November 21, 2013 00:45
JSON Output
{"ID":100,"Text":"Olamide","Inner":{"ID":400,"Name":"ComplexObject","List":[{"Text":"DataText","DataTexts":["String1","String2"],"Buffer":[19,33,45,66,23,123,55,33,55,14,67,74],"Items":["Item1","Item2"],"YesNo":true,"CreateDate":"2013-11-21T00:40:14.7568698Z"}],"Dict":{"First":{"Text":"DictData","DataTexts":null,"Buffer":null,"Items":null,"YesNo":false,"CreateDate":"0001-01-01T00:00:00"}},"MyE":2}}
@rpgmaker
rpgmaker / gist:7558538
Created November 20, 2013 06:10
Performance Result
Completed Phoenix Json in Avg 455 Milliseconds
Completed MessageShark in Avg 492 Milliseconds
Completed ProtoBuf in Avg 502 Milliseconds
Completed Phoenix Xml in Avg 1335 Milliseconds
Completed Service Stack Json in Avg 1835 Milliseconds
Completed Newton JSON.NET in Avg 2612 Milliseconds
Press any key to continue . . .
@rpgmaker
rpgmaker / gist:7558008
Created November 20, 2013 05:02
Serialization Class Structure
public enum MyEnumEx {
A = 1,
B = 2
}
[DataContract]
public class Test {
[DataMember(Order = 1)]
public int ID { get; set; }
[DataMember(Order = 2)]
@rpgmaker
rpgmaker / gist:7523009
Created November 18, 2013 05:32
Double To String (Improved)
public static string dtoa(double value) {
long trunc = (long)value;
double mantissa = (trunc < 0) ? value - trunc : trunc - value;
var left = (long)(1000000000000000 * (mantissa > 0 ? mantissa : -mantissa));
char* buf = stackalloc char[64];
char* bf = buf;