Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1123:43f1137bc72e
Date: 2014-03-30 22:13 +0200
http://bitbucket.org/pypy/stmgc/changeset/43f1137bc72e/
Log: Record the number of times events trigger, in addition to the total
time
diff --git a/c7/stm/timing.c b/c7/stm/timing.c
--- a/c7/stm/timing.c
+++ b/c7/stm/timing.c
@@ -7,6 +7,7 @@
double elapsed)
{
tl->timing[category] += elapsed;
+ tl->events[category] += 1;
}
#define TIMING_CHANGE(tl, newstate) \
@@ -58,7 +59,10 @@
void stm_flush_timing(stm_thread_local_t *tl, int verbose)
{
- TIMING_CHANGE(tl, tl->_timing_cur_state);
+ enum stm_time_e category = tl->_timing_cur_state;
+ uint64_t oldevents = tl->events[category];
+ TIMING_CHANGE(tl, category);
+ tl->events[category] = oldevents;
assert((sizeof(timer_names) / sizeof(timer_names[0])) == _STM_TIME_N);
if (verbose > 0) {
@@ -66,8 +70,8 @@
s_mutex_lock();
fprintf(stderr, "thread %p:\n", tl);
for (i = 0; i < _STM_TIME_N; i++) {
- fprintf(stderr, " %-24s %.3f s\n",
- timer_names[i], (double)tl->timing[i]);
+ fprintf(stderr, " %-24s %9u %.3f s\n",
+ timer_names[i], tl->events[i], (double)tl->timing[i]);
}
s_mutex_unlock();
}
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -86,6 +86,7 @@
(these fields are not modified on a successful commit) */
long last_abort__bytes_in_nursery;
/* timing information, accumulated */
+ uint32_t events[_STM_TIME_N];
float timing[_STM_TIME_N];
double _timing_cur_start;
enum stm_time_e _timing_cur_state;
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -24,6 +24,7 @@
size_t mem_bytes_to_clear_on_abort;
long last_abort__bytes_in_nursery;
int associated_segment_num;
+ uint32_t events[];
float timing[];
...;
} stm_thread_local_t;
diff --git a/c7/test/test_timing.py b/c7/test/test_timing.py
--- a/c7/test/test_timing.py
+++ b/c7/test/test_timing.py
@@ -7,17 +7,20 @@
def gettimer(self, n):
tl = self.tls[self.current_thread]
lib.stm_flush_timing(tl, 1)
- return tl.timing[n]
+ return tl.events[n], tl.timing[n]
- def expect_timer(self, n, expected_value):
- real = self.gettimer(n)
- print 'timer %d is %s, expecting %s' % (n, real, expected_value)
- if expected_value == 0.0:
+ def expect_timer(self, n, expected_time, expected_count='?'):
+ count, real = self.gettimer(n)
+ print 'timer %d is %d;%s, expecting %s;%s' % (n, count, real,
+ expected_count, expected_time)
+ if expected_time == 0.0:
assert real == 0.0
- elif expected_value == "nonzero":
+ elif expected_time == "nonzero":
assert real > 0.0
else:
- assert abs(real - expected_value) < 0.09
+ assert abs(real - expected_time) < 0.09
+ if expected_count != '?':
+ assert count == expected_count
def test_time_outside_transaction(self):
time.sleep(0.2)
@@ -28,18 +31,18 @@
def test_time_run_current(self):
self.start_transaction()
time.sleep(0.1)
- self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.1)
+ self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.1, 0)
time.sleep(0.1)
- self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.2, 0)
self.commit_transaction()
- self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.0)
+ self.expect_timer(lib.STM_TIME_RUN_CURRENT, 0.0, 1)
def test_time_run_committed(self):
self.start_transaction()
time.sleep(0.2)
- self.expect_timer(lib.STM_TIME_RUN_COMMITTED, 0.0)
+ self.expect_timer(lib.STM_TIME_RUN_COMMITTED, 0.0, 0)
self.commit_transaction()
- self.expect_timer(lib.STM_TIME_RUN_COMMITTED, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_COMMITTED, 0.2, 1)
def test_time_run_aborted_write_write(self):
o = stm_allocate_old(16)
@@ -50,7 +53,7 @@
self.start_transaction()
time.sleep(0.2)
py.test.raises(Conflict, stm_write, o)
- self.expect_timer(lib.STM_TIME_RUN_ABORTED_WRITE_WRITE, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_ABORTED_WRITE_WRITE, 0.2, 1)
def test_time_run_aborted_write_read(self):
o = stm_allocate_old(16)
@@ -62,7 +65,7 @@
time.sleep(0.2)
stm_write(o)
py.test.raises(Conflict, self.commit_transaction)
- self.expect_timer(lib.STM_TIME_RUN_ABORTED_WRITE_READ, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_ABORTED_WRITE_READ, 0.2, 1)
def test_time_run_aborted_inevitable(self):
self.start_transaction()
@@ -72,23 +75,23 @@
self.start_transaction()
time.sleep(0.2)
py.test.raises(Conflict, self.become_inevitable)
- self.expect_timer(lib.STM_TIME_RUN_ABORTED_INEVITABLE, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_ABORTED_INEVITABLE, 0.2, 1)
def test_time_run_aborted_other(self):
self.start_transaction()
time.sleep(0.2)
self.abort_transaction()
- self.expect_timer(lib.STM_TIME_RUN_ABORTED_OTHER, 0.2)
+ self.expect_timer(lib.STM_TIME_RUN_ABORTED_OTHER, 0.2, 1)
def test_time_minor_gc(self):
self.start_transaction()
- self.expect_timer(lib.STM_TIME_MINOR_GC, 0.0)
+ self.expect_timer(lib.STM_TIME_MINOR_GC, 0.0, 0)
stm_minor_collect()
- self.expect_timer(lib.STM_TIME_MINOR_GC, "nonzero")
- self.expect_timer(lib.STM_TIME_MAJOR_GC, 0.0)
+ self.expect_timer(lib.STM_TIME_MINOR_GC, "nonzero", 1)
+ self.expect_timer(lib.STM_TIME_MAJOR_GC, 0.0, 0)
def test_time_major_gc(self):
self.start_transaction()
- self.expect_timer(lib.STM_TIME_MAJOR_GC, 0.0)
+ self.expect_timer(lib.STM_TIME_MAJOR_GC, 0.0, 0)
stm_major_collect()
- self.expect_timer(lib.STM_TIME_MAJOR_GC, "nonzero")
+ self.expect_timer(lib.STM_TIME_MAJOR_GC, "nonzero", 1)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit