-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (75 loc) · 2.54 KB
/
Program.cs
File metadata and controls
82 lines (75 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.IO;
namespace C__tutorial
{
/// <summary>
/// MicroStopwatch class
/// </summary>
public class MicroStopwatch : System.Diagnostics.Stopwatch
{
readonly double _microSecPerTick =
1000000D / System.Diagnostics.Stopwatch.Frequency;
public MicroStopwatch()
{
if (!System.Diagnostics.Stopwatch.IsHighResolution)
{
throw new Exception("On this system the high-resolution " +
"performance counter is not available");
}
}
public long ElapsedMicroseconds
{
get
{
return (long)(ElapsedTicks * _microSecPerTick);
}
}
}
public class CSVConverter
{
public void convert(string inPath, string outPath){
String line;
try
{
StreamReader inS = new StreamReader(inPath);
StreamWriter outS = new StreamWriter(outPath);
//Read the first line of text
line = inS.ReadLine();
//Continue to read until you reach end of file
while (line != null)
{
line = line.Replace(',', '\t');
//Write a line of text
outS.WriteLine(line);
//Read the next line
line = inS.ReadLine();
}
//close the file
inS.Close();
outS.Close();
}
catch(Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
class Program
{
static void Main(string[] args)
{
MicroStopwatch uWatch = new MicroStopwatch(); // Stopwatch in the us range to time the code
uWatch.Start();
// var watch = new System.Diagnostics.Stopwatch(); // Stopwatch in the ms range to time the code
// watch.Start();
CSVConverter csc = new CSVConverter();
csc.convert("defenderParts-Full.csv", "defenderParts-Full.tsv");
uWatch.Stop();
// watch.Stop();
Console.WriteLine($"Execution Time: {uWatch.ElapsedMicroseconds} us");
Console.WriteLine($"CSV Formated:C#(Windows),{uWatch.ElapsedMicroseconds} microseconds");
Console.Write($"{Environment.NewLine}Press any key to exit...");
Console.ReadKey(true);
}
}
}