incubator-couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject CouchDB code coverage and profiling
Date Thu, 03 Jul 2008 12:52:55 GMT
Heya,
as suggest by Joe I ran Erlang's cover, cprof and
fprof tools on CouchDB.

cover:
The cover module will tell us, for each source file
how often a line was executed. Lines with a count
of 0 (zero), are never called and might be good
candidates for being nuked.

The results for each module can be found here:
http://people.apache.org/~jan/couchdb/cover/

I started the cover module, ran the browser test
suite once and then generated the result files. So
this only covers what the test suite covers.

You might notice quite a few 0-count lines:

grep -c '0..' *.html
cjson_cover.html:158
couch_btree_cover.html:183
couch_db_cover.html:143
couch_db_update_notifier_cover.html:16
couch_doc_cover.html:48
couch_event_sup_cover.html:12
couch_file_cover.html:37
couch_ft_query_cover.html:28
couch_httpd_cover.html:228
couch_key_tree_cover.html:21
couch_log_cover.html:35
couch_query_servers_cover.html:66
couch_rep_cover.html:54
couch_server_cover.html:52
couch_server_sup_cover.html:63
couch_stream_cover.html:53
couch_util_cover.html:84
couch_view_cover.html:120

How to run this yourself:
1) install CouchDB
2) Start CouchDB with ./bin/couchdb -i
3) In the resulting Erlang shell, run this:
1> cover:start().
4) Copy the CouchDB source files into the
installation:
$ cp -r couchdb-0.8-incubating/src/couchdb lib/couchdb/erlang/lib/ 
couch-0.8.0-incubating/src
5) Recompile the sources for profiling support
2> cover:compile_directory("lib/couchdb/erlang/lib/couch-0.8.0- 
incubating/src").
(adjust the path as needed).
4) Run the test suite or whatever you
want to test
5) In the Erlang console again:
3> lists:foreach(fun(Elm) -> cover:analyse_to_file(Elm,  
atom_to_list(Elm) ++ "_cover.html", [html]) end, cover:modules()).
6) stop or suspend CouchDB (ctrl-c / ctrl-z / q(). ...)
7) Look at all the *.html files in the current directory

cprof:
cprof counts the number of times a function
is called. Again, this is gathered only by
running the test suite.

The result can be found here:
http://people.apache.org/~jan/couchdb/cprof/

How to run this yourself:
1) Install CouchDB
2) Add this line to the bin/couchdb file on
line 216:
         -eval \"cprof:start()\" \
3) Start CouchDB with ./bin/couchdb -i
4) Run the browser test suite or whatever
you want to test
5) On the Erlang console that was opened with
./bin/couchdb -i
1> cprof:pause().
2> cprof:analyse().

fprof:
This gives us an idea how much time was spent
in each function. Again, this is gathered only by
running the test suite. Time can be wall clock time
and cpu time. This is wall clock time. If you like to
see CPU time, I can run that well.

The result can be found here:
http://people.apache.org/~jan/couchdb/fprof/

How to run this yourself:
1) Install CouchDB
2) Add these lines to the bin/couchdb file on
line 216 and 217:
         -eval \"fprof:start()\" \
         -eval \"fprof:trace(start, \"fprof.trace\")\" \
3) Start CouchDB with ./bin/couchdb -i
4) Run the browser test suite or whatever
you want to test
5) On the Erlang console that was opened with
./bin/couchdb -i:
1> fprof:trace(stop).
2> fprof:profile(). % This takes QUITE some time and appears
to run only on a single CPU/core. What's wrong with that?
3> fprof:analyse().

--

It'd be nice if we could integrate the generation of these
statistics into the installation somehow. For example
the optional installation of the src directory, so users
and developers can easily do a c(module). on the Erlang
shell for testing new stuff. Or do a "make profile" to get
profiling results and all that. Any ideas on how to do that?
Noah?

Cheers
Jan
--

Mime
View raw message