Skip to content

Commit

Permalink
Setup profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
camgunz committed Sep 7, 2020
1 parent 8e303ee commit 5722908
Show file tree
Hide file tree
Showing 6 changed files with 6,079 additions and 5,919 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -31,13 +31,17 @@
*.gcno
coverage/

# Profiling files
*.prof

# Testing executable
test/test-cmp
cmptest
cmptest2
cmpaddrtest
cmpmemtest
cmpnofloattest
cmpprof
cmpubtest

# Example executables
Expand All @@ -48,4 +52,3 @@ example2

# Test data
cmp_data.dat

23 changes: 18 additions & 5 deletions Makefile
Expand Up @@ -14,6 +14,11 @@ UBCFLAGS ?= -fsanitize=undefined

all: cmptest example1 example2

profile: cmpprof
@env LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=cmp.prof \
CPUPROFILE_FREQUENCY=1000 ./cmpprof
@pprof --web ./cmpprof cmp.prof

test: addrtest memtest nofloattest ubtest unittest

addrtest: cmpaddrtest
Expand All @@ -35,29 +40,35 @@ unittest: cmptest
cmp.o:
$(CC) $(CFLAGS) $(CMPCFLAGS) -fprofile-arcs -ftest-coverage -g -I. -c cmp.c

cmpprof: cmp.o
$(CC) $(CFLAGS) $(TESTCFLAGS) -fprofile-arcs -I. \
-o cmpprof cmp.o test/profile.c test/tests.c test/buf.c test/utils.c \
-lcmocka -lprofiler

cmptest: cmp.o
$(CC) $(CFLAGS) $(TESTCFLAGS) -fprofile-arcs -ftest-coverage -g -I. \
-o cmptest cmp.o test/test.c test/buf.c test/utils.c -lcmocka
-o cmptest cmp.o test/test.c test/tests.c test/buf.c test/utils.c -lcmocka

cmpnofloattest: cmp.o
$(CC) $(CFLAGS) $(NOFPUTESTCFLAGS) -fprofile-arcs -ftest-coverage -g -I. \
-o cmpnofloattest cmp.o test/test.c test/buf.c test/utils.c -lcmocka
-o cmpnofloattest cmp.o test/test.c test/tests.c test/buf.c test/utils.c \
-lcmocka

clangcmp.o:
$(CLANG) $(CFLAGS) $(CMPCFLAGS) -fprofile-arcs -ftest-coverage -g -I. \
-c cmp.c -o clangcmp.o

cmpaddrtest: clangcmp.o clean
$(CLANG) $(CFLAGS) $(TESTCFLAGS) $(ADDRCFLAGS) -I. -o cmpaddrtest cmp.c \
test/test.c test/buf.c test/utils.c -lcmocka
test/test.c test/tests.c test/buf.c test/utils.c -lcmocka

cmpmemtest: clangcmp.o clean
$(CLANG) $(CFLAGS) $(TESTCFLAGS) $(MEMCFLAGS) -I. -o cmpmemtest cmp.c \
test/test.c test/buf.c test/utils.c -lcmocka
test/test.c test/tests.c test/buf.c test/utils.c -lcmocka

cmpubtest: clangcmp.o clean
$(CLANG) $(CFLAGS) $(TESTCFLAGS) $(UBCFLAGS) -I. -o cmpubtest cmp.c \
test/test.c test/buf.c test/utils.c -lcmocka
test/test.c test/tests.c test/buf.c test/utils.c -lcmocka

example1:
$(CC) $(CFLAGS) --std=c89 -O3 -I. -o example1 cmp.c examples/example1.c
Expand All @@ -76,11 +87,13 @@ coverage:
@genhtml -q -o coverage total_coverage.info

clean:
@rm -f cmp.prof
@rm -f cmptest
@rm -f cmpaddrtest
@rm -f cmpmemtest
@rm -f cmpubtest
@rm -f cmpnofloattest
@rm -f cmpprof
@rm -f example1
@rm -f example2
@rm -f *.o
Expand Down
55 changes: 55 additions & 0 deletions test/profile.c
@@ -0,0 +1,55 @@
/*
The MIT License (MIT)
Copyright (c) 2020 Charles Gunyon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include <stdarg.h>

#include "tests.h"

int main(void) {
test_msgpack(NULL);
test_fixedint(NULL);
test_numbers(NULL);
test_nil(NULL);
test_boolean(NULL);
test_bin(NULL);
test_string(NULL);
test_array(NULL);
test_map(NULL);
test_ext(NULL);
test_obj(NULL);

#ifndef CMP_NO_FLOAT
test_float_flip(NULL);
#endif

test_skipping(NULL);
test_deprecated_limited_skipping(NULL);
test_errors(NULL);
test_version(NULL);
test_conversions(NULL);

return EXIT_SUCCESS;
}

/* vi: set et ts=2 sw=2: */

0 comments on commit 5722908

Please sign in to comment.