我将一个字符串解析成DateTime数百万次:
public static CultureInfo ci = CultureInfo.InvariantCulture;
while (!reader.EndOfStream)
{
line = reader.ReadLine();
string[] fields = line.Split(' ');
DateTime newDT = DateTime.ParseExact(fields[0], "yyyyMMddTHHmmssfff", ci);
}
Run Code Online (Sandbox Code Playgroud)
我的探查器强调ParseExact是一个很大的时间.是否有任何其他方法/方法可以将字符串解析为更快的DateTime?
关注UP1:
1)我试过这个 - 但速度是一样的
bool OK = DateTime.TryParseExact(fields[0], "yyyyMMddTHHmmssfff", null, System.Globalization.DateTimeStyles.None,out DT);
Run Code Online (Sandbox Code Playgroud)
2)
我试着编写自己的解析器 - 但这也很慢:
public static DateTime fastParse(ref string s)
{
return new DateTime(int.Parse(s.Substring(0,4)), int.Parse(s.Substring(4,2)),int.Parse(s.Substring(6,2)), int.Parse(s.Substring(9,2)),int.Parse(s.Substring(11,2)),int.Parse(s.Substring(13,2)),int.Parse(s.Substring(15, 3)));
}
Run Code Online (Sandbox Code Playgroud)
关注UP2
我尝试了Master117存储值的建议 - 再说不快 - 也许问题是构造?
public class fastParseData
{
int year;
int mon;
int day;
int hour;
int min;
string previousSlice = ""; …Run Code Online (Sandbox Code Playgroud) 我试图滞后矩阵:
> B = matrix( c(2, 4, 3, 1, 5, 7), nrow=3, ncol=2)
> B
[,1] [,2]
[1,] 2 1
[2,] 4 5
[3,] 3 7
> lag(B)
[,1] [,2]
[1,] 2 1
[2,] 4 5
[3,] 3 7
Run Code Online (Sandbox Code Playgroud)
为什么不lag(B)给:
> lag(B)
[,1] [,2]
[1,] 0 0
[2,] 2 1
[3,] 4 5
Run Code Online (Sandbox Code Playgroud) 我可以使用此链接轻松获取每日数据:
https://www.google.com/finance/getprices?q=LHA&x=ETR&i=60&p=1d&f=d,c,h,l,o,v
Run Code Online (Sandbox Code Playgroud)
但当我尝试将"1d"更改为"1y"时,我仍然可以获得1天的数据.
我想要获得2年的价值.
有没有办法做到这一点?雅虎或bing金融也没关系.
什么是如何使用SafebUffer的简单示例?也就是说,我如何创建和初始化一个?MSDN文档似乎没有显示这一点.
我正在远程调试一个java应用程序,它通常运行良好.但是,我正在编写一些新内容,现在我找到了一行,我想终止该程序.但唯一可用的按钮是暂停和断开连接.暂停,当然没有终止,断开连接会停止调试,但是远程应用程序处于任何状态,然后我必须重新启动它.
有一个终止按钮 - 但它总是灰显.如何从Eclipse调试器中选择杀死程序?
我创建了一个 3D splot。
但是我没有在 x 或 y 轴上显示足够的 tic 标签。
我试图用这个增加它们:
set xtics 0.000001
set ytics 0.000001
Run Code Online (Sandbox Code Playgroud)
这确实会增加 tic 标记的数量,但不会增加相关标签的数量。

数据片段(map.gnu):
0.00007430 0.00001000 155999
0.00007430 0.00001200 142552
0.00007430 0.00001440 141632
0.00007430 0.00001728 175229
0.00007430 0.00002074 198271
0.00007430 0.00002488 180482
0.00007430 0.00002986 121753
0.00007430 0.00003583 18049
0.00007430 0.00004300 46966
0.00007430 0.00005160 27892
0.00007430 0.00006192 20279
0.00007430 0.00008916 128832
0.00008916 0.00001000 126748
0.00008916 0.00001200 101393
0.00008916 0.00001440 143819
0.00008916 0.00001728 149303
0.00008916 0.00002074 190983
0.00008916 0.00002488 102433
0.00008916 0.00002986 13360
0.00008916 0.00003583 …Run Code Online (Sandbox Code Playgroud) 通常,"使用"是正确访问和处理文件流的优选方法.
我经常需要打开文件(如下所示).在这种情况下可以采用"使用"结构吗?
public class logger
{
private StreamWriter sw;
public logger(string fileName)
{
sw = new StreamWriter(fileName, true);
}
public void LogString(string txt)
{
sw.WriteLine(txt);
sw.Flush();
}
public void Close()
{
sw.Close();
}
}
Run Code Online (Sandbox Code Playgroud) 这有点难以阅读:
int x = 100000000;
Run Code Online (Sandbox Code Playgroud)
有没有简单的方法来写:
int x = 100,000,000;
Run Code Online (Sandbox Code Playgroud)
这样的规模是显而易见的吗?
请注意,这不是关于输出的格式.
我在表单上有一个垂直和水平可滚动的DataGridView.
我使用虚拟模式,因为底层数据表是巨大的.
当我向右滚动时,如果视图中没有完整显示最后一列,那么我会看到重复调用CellValueNeeded.
我怎样才能解决这个问题?
我的想法:
为什么CellValueNeed被反复调用部分可见的列呢?也许我可以解决这个原因.
在CelValueNeeded中 - 我可以检测到它是否部分可见并且在没有处理的情况下返回?当我检查单元格值时,"显示"和"可见"都是正确的.
我的代码:
private void grid_Data_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
{
Console.WriteLine("CellValue: " + e.RowIndex + " " + e.ColumnIndex);
if (e.RowIndex > Grid.Rows.Count - 1)
return;
DataGridView gridView = sender as DataGridView;
e.Value = Grid.Rows[e.RowIndex][e.ColumnIndex];
gridView.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex).ToString();
}
Run Code Online (Sandbox Code Playgroud)
EDIT1:
在Digitalsa1nt的回答之后,我找到了解决问题的方法.它很复杂,因为第一列的处理方式与最后一列不同.如果你要设置RowHeaders,它会有所不同.
在上面的CellValueNeed中,如果以下函数为true,我现在返回.
private bool IsPartiallyVisible(DataGridView gridView, DataGridViewCellValueEventArgs e)
{
if (gridView.FirstDisplayedScrollingColumnIndex == e.ColumnIndex)
{
if (gridView.FirstDisplayedScrollingColumnHiddenWidth != 0)
{
return true;
}
}
bool sameWidth = gridView.GetColumnDisplayRectangle(e.ColumnIndex, false).Width == gridView.GetColumnDisplayRectangle(e.ColumnIndex, true).Width;
return !sameWidth; …Run Code Online (Sandbox Code Playgroud) 在VS 2015中,我运行了CPU使用情况配置文件,我看到一个包含10%包含样本的函数(FunctionA).从其他几个函数(ParentFunctions 1,2和3)调用此函数.
当我查看3个父函数的包含样本时,它们的组合包含样本小于子函数B的IS!
如何判断哪个父项使用率最高?我习惯使用以前的探查器,其中父"CPU时间"是其子级的聚合.为什么包容性样本不能像这样工作?如何切换到能给我实际时间的东西?或者,是否有其他一些我能够分辨哪个是顽皮的父母?
c# ×6
buffer ×1
coding-style ×1
datagridview ×1
datetime ×1
eclipse ×1
filestream ×1
gnuplot ×1
java ×1
lag ×1
parsing ×1
profiling ×1
r ×1
using ×1