Commit c61eb0a3 authored by Jason Madden's avatar Jason Madden

More optimizations and clarifying comments

Compared to the previous commit:

| Benchmark          | 36_threadpool_opt_PR | 36_threadpool_opt_cond10    |
+--------------------+----------------------+-----------------------------+
| imap_unordered_seq | 1.06 ms              | 1.02 ms: 1.04x faster (-4%) |
| imap_unordered_par | 965 us               | 928 us: 1.04x faster (-4%)  |
| imap_seq           | 1.08 ms              | 1.03 ms: 1.04x faster (-4%) |
| map_seq            | 785 us               | 870 us: 1.11x slower (+11%) |
| map_par            | 656 us               | 675 us: 1.03x slower (+3%)  |
| apply              | 1.14 ms              | 1.12 ms: 1.02x faster (-2%) |
parent 59a537fe
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Benchmarks for thread locals. Benchmarks for thread pool.
""" """
from __future__ import absolute_import from __future__ import absolute_import
......
This diff is collapsed.
...@@ -597,7 +597,7 @@ class Channel(object): ...@@ -597,7 +597,7 @@ class Channel(object):
self.getters.remove(waiter) self.getters.remove(waiter)
raise raise
finally: finally:
timeout.cancel() timeout.close()
def get_nowait(self): def get_nowait(self):
return self.get(False) return self.get(False)
......
...@@ -375,13 +375,15 @@ class TestPool(greentest.TestCase): # pylint:disable=too-many-public-methods ...@@ -375,13 +375,15 @@ class TestPool(greentest.TestCase): # pylint:disable=too-many-public-methods
it = self.pool.imap_unordered(sqr_random_sleep, range(SMALL_RANGE)) it = self.pool.imap_unordered(sqr_random_sleep, range(SMALL_RANGE))
self.assertEqual(sorted(it), list(map(squared, range(SMALL_RANGE)))) self.assertEqual(sorted(it), list(map(squared, range(SMALL_RANGE))))
def test_empty(self): def test_empty_imap_unordered(self):
it = self.pool.imap_unordered(sqr, []) it = self.pool.imap_unordered(sqr, [])
self.assertEqual(list(it), []) self.assertEqual(list(it), [])
def test_empty_imap(self):
it = self.pool.imap(sqr, []) it = self.pool.imap(sqr, [])
self.assertEqual(list(it), []) self.assertEqual(list(it), [])
def test_empty_map(self):
self.assertEqual(self.pool.map(sqr, []), []) self.assertEqual(self.pool.map(sqr, []), [])
def test_terminate(self): def test_terminate(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment