diff --git a/Makefile b/Makefile index b23534e..3c4abeb 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,9 @@ CC= gcc # CFLAGS= -g -Wall -Wno-unused-function -O2 CFLAGS= -g -Wall -Wno-unused-function -O2 WRAP_MALLOC=-DUSE_MALLOC_WRAPPERS +SHOW_PERF= -DSHOW_PERF AR= ar -DFLAGS= -DHAVE_PTHREAD $(WRAP_MALLOC) +DFLAGS= -DHAVE_PTHREAD $(WRAP_MALLOC) $(SHOW_PERF) LOBJS= utils.o kthread.o kstring.o ksw.o bwt.o bntseq.o bwa.o bwamem.o bwamem_pair.o bwamem_extra.o malloc_wrap.o \ QSufSort.o bwt_gen.o rope.o rle.o is.o bwtindex.o AOBJS= bwashm.o bwase.o bwaseqio.o bwtgap.o bwtaln.o bamlite.o \ diff --git a/bwamem.c b/bwamem.c index 03e2a05..74b5d53 100644 --- a/bwamem.c +++ b/bwamem.c @@ -306,8 +306,15 @@ mem_chain_v mem_chain(const mem_opt_t *opt, const bwt_t *bwt, const bntseq_t *bn mem_chain_t tmp, *lower, *upper; mem_seed_t s; int rid, to_add = 0; +#ifdef SHOW_PERF + int64_t tmp_time = realtime_msec(); +#endif s.rbeg = tmp.pos = bwt_sa(bwt, p->x[0] + k); // this is the base coordinate in the forward-reverse reference - s.qbeg = p->info>>32; +#ifdef SHOW_PERF + tmp_time = realtime_msec() - tmp_time; + __sync_fetch_and_add(&time_bwt_sa, tmp_time); +#endif + s.qbeg = p->info >> 32; s.score= s.len = slen; rid = bns_intv2rid(bns, s.rbeg, s.rbeg + s.len); if (rid < 0) continue; // bridging multiple reference sequences or the forward-reverse boundary; TODO: split the seed; don't discard it!!! diff --git a/fastmap.c b/fastmap.c index 3511263..a3fa4ad 100644 --- a/fastmap.c +++ b/fastmap.c @@ -41,6 +41,18 @@ #include "fmt_idx.h" KSEQ_DECLARE(gzFile) +// 记录运行时间的变量 +#ifdef SHOW_PERF + +int64_t time_ksw_extend2 = 0, + time_ksw_global2 = 0, + time_ksw_align2 = 0, + time_bwt_smem1a = 0, + time_bwt_occ4 = 0, + time_bwt_sa = 0; + +#endif + extern unsigned char nst_nt4_table[256]; void *kopen(const char *fn, int *_fd); @@ -406,6 +418,13 @@ int main_mem(int argc, char *argv[]) kseq_destroy(aux.ks2); err_gzclose(fp2); kclose(ko2); } + +#ifdef SHOW_PERF + fprintf(stderr, "\n"); + fprintf(stderr, "time_bwt_sa: %f s\n", time_bwt_sa / 1000.0 / opt->n_threads); + fprintf(stderr, "\n"); +#endif + return 0; } diff --git a/fmt_idx.c b/fmt_idx.c index f35e3ab..52fe021 100644 --- a/fmt_idx.c +++ b/fmt_idx.c @@ -23,5 +23,5 @@ void BuildBwtdFromBwt(bwt_t *bwt, bwtd_t **bwtd_p) { printf("kmer size: %ld M\n", kmerSize * sizeof(kmer_range_t) / 1024 / 1024); - exit(0); + // exit(0); } \ No newline at end of file diff --git a/run.sh b/run.sh index 5664607..4724618 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,7 @@ -time ./bwa mem -t 1 -M -R @RG\\tID:normal\\tSM:normal\\tPL:illumina\\tLB:normal\\tPG:bwa \ +time ./bwa mem -t 12 -M -R @RG\\tID:normal\\tSM:normal\\tPL:illumina\\tLB:normal\\tPG:bwa \ /home/zzh/data/reference/human_g1k_v37_decoy.fasta \ /home/zzh/data/fastq/nm1.fq \ - /home/zzh/data/fastq/nm2.fq #-o /dev/null + /home/zzh/data/fastq/nm2.fq -o /dev/null # time ./bwa mem -t 1 -M -R @RG\\tID:normal\\tSM:normal\\tPL:illumina\\tLB:normal\\tPG:bwa \ # /public/home/zzh/data/reference/human_g1k_v37_decoy.fasta \ diff --git a/utils.c b/utils.c index 9ceb1be..46181db 100644 --- a/utils.c +++ b/utils.c @@ -294,6 +294,13 @@ double realtime(void) return tp.tv_sec + tp.tv_usec * 1e-6; } +int64_t realtime_msec(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (int64_t)1000 * (tv.tv_sec + ((1e-6) * tv.tv_usec)); +} + long peakrss(void) { struct rusage r; diff --git a/utils.h b/utils.h index d4d4550..1a92542 100644 --- a/utils.h +++ b/utils.h @@ -31,6 +31,17 @@ #include #include +#ifdef SHOW_PERF + +extern int64_t time_ksw_extend2, + time_ksw_global2, + time_ksw_align2, + time_bwt_smem1a, + time_bwt_occ4, + time_bwt_sa; + +#endif + #ifdef __GNUC__ // Tell GCC to validate printf format string and args #define ATTRIBUTE(list) __attribute__ (list) @@ -86,6 +97,7 @@ extern "C" { double cputime(void); double realtime(void); + int64_t realtime_msec(void); long peakrss(void); void ks_introsort_64 (size_t n, uint64_t *a);