I need to get data from a log-File into a dataset. Each line contains a index a timestamp and the process data in hex-Format. All the datalines are stored into an array of strings (each line is a member of this array).
The data is extracted and transfered into a dataset, within a loop containing:
LineNumber = Convert.ToInt32(dummystring.Substring(0, 7), 16);
year = Convert.ToInt32(dummystring.Substring(8, 2), 16) + 2000;
month = Convert.ToInt32(dummystring.Substring(10, 2), 16);
day = Convert.ToInt32(dummystring.Substring(12, 2), 16);
hour = Convert.ToInt32(dummystring.Substring(14, 2), 16);
minute = Convert.ToInt32(dummystring.Substring(16, 2), 16);
So far so good; quick and stable (500 000 lines are processed <1s).
I want to sort the entries (=lines) by creating a timestamp. So I just added one single line:
TimeStamp = new DateTime(year, month, day, hour, minute, 0);
and everything is freezing; now it takes minutes...
How can I speed this up?
I just found a good approach with ZedGraph:
....
XDate timestamp = 0;
....
year = int.Parse(dummystring.Substring(8, 2), NumberStyles.HexNumber) + 2000;
month = int.Parse(dummystring.Substring(10, 2), NumberStyles.HexNumber);
day = int.Parse(dummystring.Substring(12, 2), NumberStyles.HexNumber);
hour = int.Parse(dummystring.Substring(14, 2), NumberStyles.HexNumber);
minute = int.Parse(dummystring.Substring(16, 2), NumberStyles.HexNumber);
timestamp.SetDate(year, month, day, hour, minute, 0);
This is very fast and comfortable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.