• <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

            還需要副標(biāo)題嗎?

            導(dǎo)航

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

            統(tǒng)計(jì)

            常用鏈接

            留言簿(2)

            隨筆檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            2006年3月31日 #

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

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

            我也湊熱鬧給了一個(gè)實(shí)現(xiàn),只使用標(biāo)準(zhǔn)C++的一些算法解決此問(wèn)題,性能上還是沒有Python好,但是已經(jīng)非常接近了:
            D:\test\pytest>python test.py
            2006-03-31 14:59:19.348000
            2006-03-31 14:59:22.963000

            D:\test\pytest>cpptest
            經(jīng)過(guò)了4025.7888毫秒

            實(shí)現(xiàn):
            #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( "經(jīng)過(guò)了%I64d.%04I64d毫秒\n", (t2-t1)/10000, (t2-t1)%10000 );
            }
            對(duì)比的其他兩個(gè)實(shí)現(xiàn):
            1、vector + sort + unique
            2、set
            最后還是我的這個(gè)實(shí)現(xiàn)好一點(diǎn):)
            PS:編譯器用的是VC2005

            再PS,寫了上面那個(gè)PS之后突然想看看VC2003怎么樣,于是測(cè)試一下,驚人的發(fā)現(xiàn):
            D:\test\pytest>cpptest2
            經(jīng)過(guò)了3234.6512毫秒
            速度已經(jīng)超越了Python
            .^_^。滿心歡喜結(jié)束這個(gè)討論旅程

            posted @ 2006-03-31 15:28 音樂(lè)蟲子 閱讀(2671) | 評(píng)論 (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 音樂(lè)蟲子 閱讀(408) | 評(píng)論 (0)編輯 收藏

            2006年2月9日 #

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

            just mark it:)

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

            posted @ 2006-02-09 17:08 音樂(lè)蟲子 閱讀(845) | 評(píng)論 (5)編輯 收藏

            僅列出標(biāo)題  
            久久久黄色大片| 国产精品成人99久久久久| 日日狠狠久久偷偷色综合96蜜桃| 久久综合综合久久97色| 国内精品伊人久久久久网站| 久久天天躁狠狠躁夜夜2020| 国产毛片欧美毛片久久久| 97久久久精品综合88久久| 蜜臀久久99精品久久久久久 | 久久亚洲欧美国产精品| 国产精品无码久久久久 | 99久久精品国产麻豆| 久久久久婷婷| 国内精品久久久久影院免费| 偷窥少妇久久久久久久久| 久久精品免费观看| 久久天天躁狠狠躁夜夜躁2O2O| 久久久噜噜噜久久| 成人综合伊人五月婷久久| 国产欧美久久久精品影院| 麻豆精品久久久一区二区| 久久影院综合精品| 狠狠综合久久AV一区二区三区 | 国产精品99久久不卡| 国产精品18久久久久久vr| 久久亚洲国产成人影院| 久久久久国产一级毛片高清板| 91久久精一区二区三区大全| 国产欧美久久久精品影院| 亚洲美日韩Av中文字幕无码久久久妻妇 | 久久精品国产一区| 久久综合给合久久国产免费| 一本一道久久综合狠狠老| 中文字幕精品久久| 一级做a爰片久久毛片看看 | 久久亚洲精品国产亚洲老地址| 精品视频久久久久| 久久精品免费网站网| 成人精品一区二区久久久| 一本一道久久精品综合| 国产精品gz久久久|