More Related Content
Similar to MySQL新技术探索与实践 (20)
MySQL新技术探索与实践
- 5. ICC vs GCC(1) 硬件环境 CPU : Intel Xoen 5410 内存: 24G 硬盘: 10*15k SAS RAID10
- 6. ICC vs GCC(2) 硬件环境 CPU : Intel Xoen 5520 内存: 24G 硬盘: 10*15k SAS RAID10 MySQL : 5.1.40 Enterprise
- 10. EXT3 vs XFS(1) 硬件环境 CPU : Intel Xoen 5520 内存: 24G 硬盘: 10*15k SAS RAID10 MySQL : 5.1.40 Enterprise
- 11. EXT3 vs XFS(2) 硬件环境 CPU : Intel Xoen 5520 内存: 24G 硬盘: 10*15k SAS RAID10 MySQL : 5.1.40 Enterprise
- 19. HS vs MC vs SQL 硬件环境 CPU : Intel Xoen 5520 内存: 24G 硬盘: 10*15k SAS RAID10 MySQL : 5.1.48
Editor's Notes
- #include <iostream> #include <cstdlib> #include <time.h> #include <math.h> #define MAXN 2000000000 using namespace std; // 计时器 class Timer { public : // 构造函数 Timer (); // 析构函数 ~Timer (); // 开始计时 void begin(); // 计时结束 void end(); // 获取时间 float get_time(); private : clock_t start, finish; float time; }; Timer::Timer () { start = 0; finish = 0; } Timer::~Timer () { start = 0; finish = 0; } void Timer::begin () { start = clock(); } void Timer::end () { finish = clock(); } float Timer::get_time() { time = (float)(finish-start)/CLOCKS_PER_SEC; return time; } float pi(int n) { float s=0; float a; for(int i=1;i<=n;++i) { if(i%2==0) { a = 1.0/(2*i-1); s -= a; } else { a = 1.0/(2*i-1); s += a; } } s *= 4; return s; }; float sqrt1 (int n) { float a = 0; for (int i=1; i<=n; ++i) { /*if (i%2 == 0) { a += 1/sqrt(i); } else { a -= 1/sqrt(i); }*/ a += 1/sqrt(i); } return a; } float sqrt2 (float x) { float xhalf = 0.5f*x; int i = *(int*)&x; // get bits for floating VALUE i = 0x5f375a86- (i>>1); // gives initial guess y0 x = *(float*)&i; // convert bits BACK to float x = x*(1.5f-xhalf*x*x); // Newton step, repeating increases accuracy return x; } float sqrt3 (int n) { float a = 0; for (int i=1; i<=n; ++i) { /*if (i%2 == 0) { a += sqrt2((float)i); } else { a -= sqrt2((float)i); }*/ a += sqrt2((float)i); } return a; } int main() { Timer timer; timer.begin (); float p = pi(MAXN); timer.end (); cout<<&quot;1.PI Test(NULL):&quot;<<timer.get_time()<<endl; timer.begin (); cout<<&quot;\\n2.PI=&quot;<<pi(MAXN)<<endl; timer.end (); cout<<&quot;2.PI Test:&quot;<<timer.get_time()<<endl; timer.begin (); sqrt1(MAXN); timer.end (); cout<<&quot;\\n3.system sqrt Test(NULL):&quot;<<timer.get_time()<<endl; timer.begin (); cout<<&quot;\\n4.sqrt1=&quot;<<sqrt1(MAXN)<<endl; timer.end (); cout<<&quot;4.system sqrt Test:&quot;<<timer.get_time()<<endl; timer.begin (); float s = sqrt3(MAXN); timer.end (); cout<<&quot;\\n5.newton sqrt Test(NULL):&quot;<<timer.get_time()<<endl; timer.begin (); cout<<&quot;\\n6.sqrt2=&quot;<<sqrt3(MAXN)<<endl; timer.end (); cout<<&quot;6.newton sqrt Test:&quot;<<timer.get_time()<<endl; return 0; }
- GCC 编译参数: CC=gcc \\ CXX=gcc \\ CHOST=&quot;x86_64-pc-linux-gnu&quot; \\ CFLAGS=&quot; -O3 \\ -fomit-frame-pointer \\ -pipe \\ -march=nocona \\ -mfpmath=sse \\ -m128bit-long-double \\ -mmmx \\ -msse \\ -msse2 \\ -maccumulate-outgoing-args \\ -m64 \\ -ftree-loop-linear \\ -fprefetch-loop-arrays \\ -freg-struct-return \\ -fgcse-sm \\ -fgcse-las \\ -frename-registers \\ -fforce-addr \\ -fivopts \\ -ftree-vectorize \\ -ftracer \\ -frename-registers \\ -minline-all-stringops \\ -fno-exceptions \\ -fno-rtti \\ -fbranch-target-load-optimize2 \\ -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free &quot; \\ CXXFLAGS=&quot;${CFLAGS}&quot; \\ LDFLAGS=&quot; -ltcmalloc_minimal -lstdc++ &quot; \\ ./configure \\ --with-server-suffix=-alibaba-edition \\ --with-mysqld-user=mysql \\ --with-plugins=heap,innodb_plugin,myisam,partition \\ --with-charset=utf8 \\ --with-collation=utf8_general_ci \\ --with-extra-charsets=gbk,utf8,ascii \\ --with-big-tables \\ --with-fast-mutexes \\ --with-zlib-dir=bundled \\ --with-readline \\ --with-pthread \\ --enable-assembler \\ --enable-profiling \\ --enable-local-infile \\ --enable-thread-safe-client \\ --with-mysqld-ldflags=-all-static \\ --without-embedded-server \\ --without-query-cache \\ --without-geometry \\ --without-debug \\ --without-ndb-binlog \\ --without-ndb-debug ICC 参数: CC=icc \\ CXX=icpc \\ LD=xild \\ AR=xiar \\ CFLAGS=&quot;-O3 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -unroll2 -ip -fp-model fast=1 -restrict -fno-exceptions -fno-rtti -no-prec-div -fno-implicit-templates -static-intel -static-libgcc -static -xSSE2 -axSSE2 &quot; \\ CXXFLAGS=&quot;${CFLAGS}&quot; \\ CPPFLAGS=&quot; -I/usr/alibaba/icc/include &quot; \\ LDFLAGS=&quot; -L/usr/alibaba/icc/lib/intel64/ -lrt -ltcmalloc_minimal -lstdc++ &quot; \\ ./configure \\ --with-server-suffix=-alibaba-edition \\ --with-mysqld-user=mysql \\ --with-plugins=heap,innodb_plugin,myisam,partition \\ --with-charset=utf8 \\ --with-collation=utf8_general_ci \\ --with-extra-charsets=gbk,utf8,ascii \\ --with-big-tables \\ --with-fast-mutexes \\ --with-zlib-dir=bundled \\ --with-readline \\ --with-pthread \\ --enable-assembler \\ --enable-profiling \\ --enable-local-infile \\ --enable-thread-safe-client \\ --with-mysqld-ldflags=-all-static \\ --without-embedded-server \\ --without-query-cache \\ --without-geometry \\ --without-debug \\ --without-ndb-binlog \\ --without-ndb-debug
- 格式化参数: mkfs.xfs -f -i size=512,attr=2 -l size=128m,lazy-count=1 -d su=64k,sw=5 -L data /dev/sdb1 mount 参数: /dev/sdb1 /data xfs defaults,noatime,nodiratime,noikeep,nobarrier,allocsize=8M,attr2,largeio,inode64,swalloc 0 0
- 测试场景为 1G 数据不断执行 SELECT 或 GET 操作同一条记录