惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
L
LangChain Blog
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
About on SuperTechFans
博客园_首页
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
美团技术团队
V
V2EX

博客园 - 以天

用DTS从Excel中往SQL SERVER导入数据的问题 - 以天 - 博客园 [AS3]DispatchEvent的古怪问题 FLASH的安全策略,PNG/XML HttpHandle中间的Session的使用 与 web.config中HttpModel 用Eclipse+CDT+MinGW+SVN搭建跨平台的开发环境 - 以天 - 博客园 让你的WCF服务支持WebGet属性 - 以天 - 博客园 QC9的安装心得 AS3中的Timer和Event.EnterFrame的区别 XFile中的UV坐标(Panda Xfile导出)的坐标系和3dMax的坐标系不对 [WCF]今天做了一个WCF的测试,测试的结果让我很出乎意料,但百思不得其解啊。 [AS]Sprite的buttonMode带来的问题 [Flash]FMS发布live视频时会出现第一次发布不成功 [Flash]Flash在网页中不能适应用户显示/影藏IE的状态栏时改变舞台大小 [C#]10进制到Excel的26进制的转换函数 [其他]水晶报表中的人民币大写函数 [JS]关于Js文件的导入, [AS3]使用LoadInfo的addEventListener时一定要注意结束时调用removeEventListener 各行业的龙头股 (整理) [AS3]单个图片进行角色动作化处理【转】
C++和.net的对象创建
以天 · 2008-10-08 · via 博客园 - 以天

最近一直在思考要不要为.net写一个对象池。看了后面的结果,我看是不用了。.net的内存管理实际上已经进入了一次优化。也许就是我们常用的对象池。

先看.net代码:

[TestMethod]

public void TestAllocPakcage()

{

byte[] pkg;

for (int i = 0; i < 50000; i++)

{

pkg = new byte[2048];

pkg[100] = 1;

}

}

测试结果:

再看c++代码:

 #include "stdafx.h"

#include "time.h"

class Packet

{

public:

    char buffer[2024];

};

int _tmain(int argc, _TCHAR* argv[])

{

    Packet* test;

    clock_t start,end;

    start = clock();

    for(int i = 0; i < 50000; i ++)

    {

        test = new Packet();

        for(int j = 0;j < 100; j ++)

        {

            test->buffer[j] = j;

        }

        delete test;

    }

    end = clock();

    double duration = (double)(end - start) / CLOCKS_PER_SEC;

    printf( "%f seconds\n", duration );

    getchar();

    return 0;

}

测试结果:

如果有什么错误,请大家指出。