原始程式碼
https://github.com/poi5305/utility/blob/master/bits_fields_speed_test.cpp
//=========================================//RT.start_timer("old");for(uint32_t i=0; i < genome.size()/4; i++){uint8_t cpint ( table[ genome[ (i<<2)+0 ] ] );for(uint32_t j=1; j<4; j++){cpint = cpint << 2;cpint = cpint | table[ genome[ (i<<2)+j ]];}compressed_genome_2[i] = cpint;}RT.print_timer("old");//=========================================////=========================================//RT.start_timer("bits fields version 1");for(uint32_t i=0; i < genome.size()/4; i++){compressed_genome_1[i].bits.b4 = table[ genome[ (i<<2)+0 ] ];compressed_genome_1[i].bits.b3 = table[ genome[ (i<<2)+1 ] ];compressed_genome_1[i].bits.b2 = table[ genome[ (i<<2)+2 ] ];compressed_genome_1[i].bits.b1 = table[ genome[ (i<<2)+3 ] ];}RT.print_timer("bits fields version 1");//=========================================////=========================================//RT.start_timer("bits fields version 2");for(uint32_t i=0; i < genome.size()/4; i++){compressed_genome_3[i].bits = {table[ genome[ (i<<2)+3 ] ],table[ genome[ (i<<2)+2 ] ],table[ genome[ (i<<2)+1 ] ],table[ genome[ (i<<2)+0 ] ]};}RT.print_timer("bits fields version 2");//=========================================//
/*Mac clang -O2Genome size: 400000000old: 7315bits fields version 1: 7258bits fields version 2: 6582Values of three methods are the samebits fields version 3: 6484Mac clang -O3Genome size: 400000000old: 398bits fields version 1: 779bits fields version 2: 500Values of three methods are the samebits fields version 3: 505Ubuntu g++-4.8 -O2Genome size: 400000000old: 1273bits fields version 1: 2079bits fields version 2: 1019Values of three methods are the samebits fields version 3: 981Ubuntu g++-4.8 -O3Genome size: 400000000old: 1335bits fields version 1: 2086bits fields version 2: 995Values of three methods are the samebits fields version 3: 937*/
沒有留言:
張貼留言