summaryrefslogtreecommitdiff
path: root/dist/stat.py
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-11-16 21:02:27 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-11-16 21:02:27 +1100
commit3bdf27747a59f4af52244ddc519932de9e2ad6d4 (patch)
tree3baaece5ed8a7a7368868e0ac58f1ca4d8e7b795 /dist/stat.py
parentc7258fd32736db32a01981c12625213d0b865310 (diff)
downloadmongo-3bdf27747a59f4af52244ddc519932de9e2ad6d4.tar.gz
Add a "size of checkpoint" statistic.
Merge statistics from file and LSM sources into a "data source" statistic structure. Rename and regroup some shared stastistics. Make statistics constant names upper case. Add a helper to the Python API to lookup in a cursor in a simple expression. closes #232
Diffstat (limited to 'dist/stat.py')
-rw-r--r--dist/stat.py74
1 files changed, 25 insertions, 49 deletions
diff --git a/dist/stat.py b/dist/stat.py
index bbaaa08b06c..a70c09e8a63 100644
--- a/dist/stat.py
+++ b/dist/stat.py
@@ -1,24 +1,20 @@
# Read the source files and output the statistics #defines and allocation code.
import re, string, sys, textwrap
-from operator import attrgetter
from dist import compare_srcfile
from dist import source_paths_list
# Read the source files.
-from stat_data import btree_stats, connection_stats, lsm_stats
+from stat_data import dsrc_stats, connection_stats
-# print_struct --
-# Print the structures for the stat.h file.
-def print_struct(title, name, list):
+def print_struct(title, name, stats):
+ '''Print the structures for the stat.h file.'''
f.write('/*\n')
- f.write(' * Statistics entries for ' + title + ' handle.\n')
+ f.write(' * Statistics entries for ' + title + '.\n')
f.write(' */\n')
f.write('struct __wt_' + name + '_stats {\n')
- # Sort the structure fields by their description, so the eventual
- # disply is sorted by string.
- for l in sorted(list, key=attrgetter('desc')):
+ for l in stats:
f.write('\tWT_STATS ' + l.name + ';\n')
f.write('};\n\n')
@@ -35,59 +31,41 @@ for line in open('../src/include/stat.h', 'r'):
elif line.count('Statistics section: BEGIN'):
f.write('\n')
skip = 1
- print_struct('BTREE', 'btree', btree_stats)
- print_struct('CONNECTION', 'connection', connection_stats)
- print_struct('LSM', 'lsm', lsm_stats)
+ print_struct('data sources', 'dsrc', dsrc_stats)
+ print_struct('connections', 'connection', connection_stats)
f.close()
compare_srcfile(tmp_file, '../src/include/stat.h')
-# print_define --
-# Print the #defines for the wiredtiger.in file.
-def print_define():
- # Sort the structure fields by their description so they match
- # the structure lists.
+def print_defines():
+ '''Print the #defines for the wiredtiger.in file.'''
f.write('''
/*!
- * @name Statistics for connection handles
+ * @name Connection statistics
* @anchor statistics_keys
* @anchor statistics_conn
- * Statistics in WiredTiger are accessed through cursors with \c "statistics:"
- * URIs. Individual statistics can be queried through the cursor using the
- * following keys.
+ * Statistics are accessed through cursors with \c "statistics:" URIs.
+ * Individual statistics can be queried through the cursor using the following
+ * keys.
* @{
*/
''')
- for v, l in enumerate(sorted(connection_stats, key=attrgetter('desc'))):
+ for v, l in enumerate(connection_stats):
f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70)))
- f.write('#define\tWT_STAT_' + l.name + "\t" *
- max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) +
+ f.write('#define\tWT_STAT_CONN_' + l.name.upper() + "\t" *
+ max(1, 6 - int((len('WT_STAT_CONN_' + l.name)) / 8)) +
str(v) + '\n')
f.write('''
/*!
* @}
- * @name Statistics for file objects
- * @anchor statistics_file
+ * @name Statistics for data sources
+ * @anchor statistics_dsrc
* @{
*/
''')
- for v, l in enumerate(sorted(btree_stats, key=attrgetter('desc'))):
+ for v, l in enumerate(dsrc_stats):
f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70)))
- f.write('#define\tWT_STAT_' + l.name + "\t" *
- max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) +
- str(v) + '\n')
- f.write('/*! @} */\n')
- f.write('''
-/*!
- * @}
- * @name Statistics for lsm objects
- * @anchor statistics_lsm
- * @{
- */
-''')
- for v, l in enumerate(sorted(lsm_stats, key=attrgetter('desc'))):
- f.write('/*! %s */\n' % '\n * '.join(textwrap.wrap(l.desc, 70)))
- f.write('#define\tWT_STAT_' + l.name + "\t" *
- max(1, 6 - int((len('WT_STAT_') + len(l.name)) / 8)) +
+ f.write('#define\tWT_STAT_DSRC_' + l.name.upper() + "\t" *
+ max(1, 6 - int((len('WT_STAT_DSRC_' + l.name)) / 8)) +
str(v) + '\n')
f.write('/*! @} */\n')
@@ -104,14 +82,13 @@ for line in open('../src/include/wiredtiger.in', 'r'):
elif line.count('Statistics section: BEGIN'):
f.write(' */\n')
skip = 1
- print_define()
+ print_defines()
f.write('/*\n')
f.close()
compare_srcfile(tmp_file, '../src/include/wiredtiger.in')
-# print_func --
-# Print the functions for the stat.c file.
def print_func(name, list):
+ '''Print the functions for the stat.c file.'''
f.write('''
int
__wt_stat_alloc_''' + name + '''_stats(WT_SESSION_IMPL *session, WT_''' +
@@ -145,7 +122,7 @@ __wt_stat_clear_''' + name + '''_stats(WT_STATS *stats_arg)
for l in sorted(list):
# Items marked permanent aren't cleared by the stat clear
# methods.
- if not l.config.count('perm'):
+ if not l.flags.get('perm', 0):
f.write('\tstats->' + l.name + '.v = 0;\n');
f.write('}\n')
@@ -154,8 +131,7 @@ f = open(tmp_file, 'w')
f.write('/* DO NOT EDIT: automatically built by dist/stat.py. */\n\n')
f.write('#include "wt_internal.h"\n')
-print_func('btree', btree_stats)
+print_func('dsrc', dsrc_stats)
print_func('connection', connection_stats)
-print_func('lsm', lsm_stats)
f.close()
compare_srcfile(tmp_file, '../src/support/stat.c')