-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loop option to track per thread cpu clock
- Loading branch information
erin
committed
Feb 8, 2013
1 parent
7ea4c7a
commit 1270397
Showing
4 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
from diesel import Loop, fork, Application, clock, sleep | ||
|
||
def usage(): | ||
u = os.times() | ||
return u[0] + u[1] | ||
|
||
def not_always_busy_worker(clocker): | ||
start = clocker() | ||
|
||
sleeping = 6 | ||
while sleeping: | ||
use = usage() | ||
for i in xrange(10000000): # do some work to forward cpu seconds | ||
pass | ||
sleep(0.1) # give up control | ||
sleeping -= 0.5 | ||
|
||
end = clocker() | ||
print "start ", start, " end ", end, " diff ", end - start | ||
|
||
def spawn_busy_workers(): | ||
for _ in xrange(0,3): | ||
fork(not_always_busy_worker, clock) | ||
|
||
a = Application() | ||
a.add_loop(Loop(spawn_busy_workers, track=True)) | ||
a.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
additional_requires = [] | ||
|
||
VERSION = "3.0.11" | ||
VERSION = "3.0.12" | ||
|
||
setup(name="diesel", | ||
version=VERSION, | ||
|