我有一个WPF应用程序,可以在大型数据集中进行大量匹配,目前它使用C#和LINQ来匹配POCO并在网格中显示.随着所包含数据集的数量增加,数据量增加,我被要求查看性能问题.我今天晚上测试的一个假设是,如果我们将一些代码转换为C++ CLI,是否存在实质性差异.为此,我编写了一个简单的测试,创建了List<>5,000,000个项目,然后做了一些简单的匹配.基本对象结构是:
public class CsClassWithProps
{
public CsClassWithProps()
{
CreateDate = DateTime.Now;
}
public long Id { get; set; }
public string Name { get; set; }
public DateTime CreateDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我注意到的一件事是,平均而言,对于创建列表的简单测试,然后构建具有偶数ID的所有对象的子列表,C++/CLI代码在我的开发机器上慢了大约8%(64位Win8) ,8GB的RAM).例如,创建和过滤C#对象的情况需要大约7秒,而C++/CLI代码平均需要大约8秒.好奇,为什么这会是这样,我用ILDASM看看发生了什么在幕后发生的事情,并惊讶地看到,C++/CLI代码是在构造函数额外的步骤.首先是测试代码:
static void CreateCppObjectWithMembers()
{
List<CppClassWithMembers> results = new List<CppClassWithMembers>();
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < Iterations; i++)
{
results.Add(new CppClassWithMembers() { Id = i, Name = string.Format("Name {0}", i) });
}
var halfResults = …Run Code Online (Sandbox Code Playgroud) 我正在测试不同的IDE和QtCreator是我最喜欢的,但似乎不支持auto关键字?

我是c ++的新手,但机器人变体应该是一样的吗?(也许是唯一的指针)但是我没有得到变量的自动完成功能o1
我只是犯了一个错误,或者QtCreator不支持自动?
我是Visual Studio和C#的新手.我习惯使用XCode和Objective-C,但现在正在尝试编写Windows 8应用程序.我试图FileSystemWatcher在用户单击我的应用程序中的按钮时设置,但由于某种原因,Visual Studio拒绝识别我可以执行此操作并抛出错误.这是我写的一个例子:
using System;
using System.IO;
...
namespace My_APP
{
...
public sealed partial class MainPage : My_App.Common.LayoutAwarePage
{
...
public void button_click_1(object sender, RoutedEventArgs e)
{
FileSystemWatcher watch = new FileSystemWatcher();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在FileSystemWatcher以红色与错误下划线两次:Error 1 The type or namespace name 'FileSystemWatcher' could not be found (are you missing a using directive or an assembly reference?) 我在做什么错了(我敢肯定,这是令人难以置信的东西简单).
c# filesystemwatcher visual-studio microsoft-metro visual-studio-2012
我试图回填我对 C 内存管理的了解。我主要来自脚本编写和管理背景,我想了解有关 C 和 C++ 的更多信息。为此,我一直在阅读几本书,其中包括以下realloc用于修剪一串空格的示例:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* trim(char* phrase)
{
char* old = phrase;
char* new = phrase;
while(*old == ' ') {
old++;
}
while(*old) {
*(new++) = *(old++);
}
*new = 0;
return (char*)realloc(phrase, strlen(phrase)+1);
}
int main ()
{
char* buffer = (char*)malloc(strlen(" cat")+1);
strcpy(buffer, " cat");
printf("%s\n", trim(buffer));
free(buffer);
buffer=NULL;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我尽职尽责地复制了这个例子,并用c99 -Wall -Wpointer-arith -O3 -pedantic -march=native. 我没有收到任何编译错误,该应用程序运行并执行书中承诺的操作,但是当我针对 valgrind 运行它时,我收到关于 invalid 的错误realloc …
我将给出一组我在w3schools XML示例中找到的简单xml行.
我想知道如何从控制台应用程序访问这些数据(我通过控制台应用程序项目插入了app.config)
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
Run Code Online (Sandbox Code Playgroud) c# ×3
autocomplete ×1
c ×1
c++ ×1
c++-cli ×1
c++11 ×1
performance ×1
qt-creator ×1
realloc ×1
testing ×1
valgrind ×1
visual-c++ ×1
xml ×1