Adds support for gprof.

Little speed improvments.
This commit is contained in:
Andrea Mazzoleni 2011-06-21 23:57:09 +02:00
parent 7acaf53dc9
commit 132ccef591
3 changed files with 24 additions and 14 deletions

View file

@ -70,6 +70,7 @@ clean-local:
rm -f *.gcda *.gcno *.gcov
rm -rf cov
rm -f lcov.info
rm -f gmon.out
maintainer-clean-local:
rm -f snapraid.1 snapraid.txt
@ -267,7 +268,7 @@ check-local:
# Manual testing
CHECK = ./snapraid -v -c test-raid5.conf sync
CHECK = ./snapraid -S -c test-raid5.conf diff
valgrind:
valgrind \
@ -284,6 +285,7 @@ callgrind:
--tool=callgrind \
--dump-instr=yes \
--trace-jump=yes \
--collect-systime=yes \
-v $(CHECK) \
2> callgrind.log
tail callgrind.log

View file

@ -42,7 +42,7 @@ dnl Checks for library functions.
AC_SYS_LARGEFILE
AC_CHECK_FUNCS([memset strchr strerror strrchr mkdir])
AC_CHECK_FUNCS([getopt getopt_long snprintf vsnprintf])
AC_CHECK_FUNCS([ftruncate fsync access posix_fallocate posix_fadvise pread pwrite fgetc_unlocked ferror_unlocked fnmatch])
AC_CHECK_FUNCS([ftruncate fsync access posix_fallocate posix_fadvise pread pwrite getc_unlocked ferror_unlocked fnmatch])
dnl Checks for architecture
AC_C_BIGENDIAN
@ -71,6 +71,14 @@ AS_IF([test "x$with_crypto" != xno], [
])
])
AC_ARG_ENABLE([profiler],
[AS_HELP_STRING([--enable-profiler],[enable the use of gprof for code coverage])],
[
TESTENV=""
CFLAGS="-O2 -pg -g"
],
[])
AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],[enable the use of gcov for code coverage])],
[

24
util.c
View file

@ -29,11 +29,11 @@ int strgets(char* s, unsigned size, FILE* f)
int c;
while (1) {
#if HAVE_FGETC_UNLOCKED
c = fgetc_unlocked(f);
#if HAVE_GETC_UNLOCKED
c = getc_unlocked(f);
#else
c = fgetc(f);
#endif
c = getc(f);
#endif
if (c == EOF || c == '\n')
break;
@ -137,23 +137,23 @@ char* strdechex(void* void_data, unsigned data_len, char* str)
unsigned char b1;
c0 = *str;
if (c0 >= 'A' && c0 <= 'F')
b0 = c0 - 'A' + 10;
if (c0 >= '0' && c0 <= '9')
b0 = c0 - '0';
else if (c0 >= 'a' && c0 <= 'f')
b0 = c0 - 'a' + 10;
else if (c0 >= '0' && c0 <= '9')
b0 = c0 - '0';
else if (c0 >= 'A' && c0 <= 'F')
b0 = c0 - 'A' + 10;
else
return str;
++str;
c1 = *str;
if (c1 >= 'A' && c1 <= 'F')
b1 = c1 - 'A' + 10;
if (c1 >= '0' && c1 <= '9')
b1 = c1 - '0';
else if (c1 >= 'a' && c1 <= 'f')
b1 = c1 - 'a' + 10;
else if (c1 >= '0' && c1 <= '9')
b1 = c1 - '0';
else if (c1 >= 'A' && c1 <= 'F')
b1 = c1 - 'A' + 10;
else
return str;
++str;