• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Simple is beautifull

            還需要副標題嗎?

            導航

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            統計

            常用鏈接

            留言簿(2)

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            2006年3月31日 #

            為什么Python的性能比較好呢?

            在vckbase上看到有討論這樣一個問題:
            http://blog.vckbase.com/jzhang/archive/2006/03/28/18807.html
            CSDN的朋友參考了Python的實現源碼給出有如下的解答:
            http://blog.csdn.net/imjj/archive/2006/03/31/645163.aspx?Pending=true
            性能上已經比Python好了,但是該解答畢竟是針對了具體的應用,比如定死了hash桶的大小之類的。

            我也湊熱鬧給了一個實現,只使用標準C++的一些算法解決此問題,性能上還是沒有Python好,但是已經非常接近了:
            D:\test\pytest>python test.py
            2006-03-31 14:59:19.348000
            2006-03-31 14:59:22.963000

            D:\test\pytest>cpptest
            經過了4025.7888毫秒

            實現:
            #include <windows.h>??????//? just for time counting

            #include <list>
            #include <string>
            #include <fstream>
            #include <algorithm>

            using namespace std;
            int main( void )
            {
            ?__int64 t1, t2;
            ?GetSystemTimeAsFileTime( (LPFILETIME)&t1 );

            ?list<string> emails;
            ?ifstream infile("email2.txt");
            ?ofstream oufile("email_cpp.txt");
            ?copy( istream_iterator<string>(infile), istream_iterator<string>(), back_inserter(emails) );
            ?emails.unique();
            ?ofstream outfile( "email_cpp.txt" );
            ?copy( emails.begin(), emails.end(), ostream_iterator<string>(outfile,"\n") );

            ?GetSystemTimeAsFileTime( (LPFILETIME)&t2 );
            ?printf( "經過了%I64d.%04I64d毫秒\n", (t2-t1)/10000, (t2-t1)%10000 );
            }
            對比的其他兩個實現:
            1、vector + sort + unique
            2、set
            最后還是我的這個實現好一點:)
            PS:編譯器用的是VC2005

            再PS,寫了上面那個PS之后突然想看看VC2003怎么樣,于是測試一下,驚人的發現:
            D:\test\pytest>cpptest2
            經過了3234.6512毫秒
            速度已經超越了Python
            .^_^。滿心歡喜結束這個討論旅程

            posted @ 2006-03-31 15:28 音樂蟲子 閱讀(2671) | 評論 (4)編輯 收藏

            2006年2月12日 #

            類型選擇

            // test7.cpp : Defines the entry point for the console application.
            //

            #include "stdafx.h"

            using namespace std;
            using namespace boost;

            namespace
            {
             template<typename T> char checkSize(T*);
             template<typename T> long checkSize(...);
            }

            template<typename FIRST, typename SECOND>
            struct SameType
            {
             enum{value = sizeof(char) == sizeof(checkSize<FIRST>((SECOND*)0)) };
            };


            class IFoo
            {
            public:
             virtual void bar() = 0;
            };

            class Foo: public IFoo
            {
            public:
             virtual void bar(){ cout<<"bar()"<<endl; };
            };

            template<int>
            class TypeSelect
            {
            public:
             template<typename T>
              TypeSelect(T& r){}
            };

            template<> class TypeSelect<true>
            {
            public:
             template<typename T>
              TypeSelect(T& r)
             {
              r.bar();
             } 
            };

            template<class T> void func( T& t )
            {
             (TypeSelect<SameType<IFoo, T>::value>(t));          
            }

            int main()
            {
             Foo x;
             int y;
             func(x);
             func(y);
            }

            posted @ 2006-02-12 11:27 音樂蟲子 閱讀(409) | 評論 (0)編輯 收藏

            2006年2月9日 #

            boost::thread 中使用類成員作為線程入口

            just mark it:)

            boost::thread trd1(boost::bind(&TheClass::theMember), &obj);

            posted @ 2006-02-09 17:08 音樂蟲子 閱讀(846) | 評論 (5)編輯 收藏

            僅列出標題  
            伊人色综合久久天天人守人婷| 日韩精品无码久久久久久| 青青草国产精品久久久久| 国产一区二区精品久久岳| 伊人情人综合成人久久网小说| 中文字幕无码精品亚洲资源网久久| 久久人爽人人爽人人片AV| 久久精品国产黑森林| 久久久久亚洲AV无码专区首JN | 色天使久久综合网天天| 亚洲精品无码久久一线| 久久精品无码一区二区三区免费| 久久亚洲精品无码aⅴ大香| 久久精品人人槡人妻人人玩AV| 久久久黄片| 久久综合久久久| 亚洲国产精品久久电影欧美| 精品久久久久国产免费 | 国产A级毛片久久久精品毛片| AAA级久久久精品无码片| 久久婷婷色综合一区二区| 91精品国产91久久久久久| 天天躁日日躁狠狠久久| 2021国产精品久久精品| 欧美亚洲国产精品久久久久| 91精品国产高清久久久久久国产嫩草| 天天躁日日躁狠狠久久| 国产成年无码久久久免费| 久久久久99这里有精品10| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久激情亚洲精品无码?V| 精品久久久久久久久中文字幕| 亚洲伊人久久精品影院| 久久精品国产久精国产一老狼| 久久婷婷午色综合夜啪| 久久人人添人人爽添人人片牛牛 | 99久久国产主播综合精品| 久久综合久久综合九色| 国产成人精品久久亚洲高清不卡 | 国产精品久久久久久搜索| 国内精品久久久久影院优|