wip
parent
40343490f2
commit
0dd99501e5
|
|
@ -14,9 +14,9 @@ def main():
|
|||
|
||||
def get_args():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("-n", type=int, help="queue capacity", default=3)
|
||||
ap.add_argument("-m", type=int, help="queue fill line", default=3)
|
||||
ap.add_argument("-r", type=int, help="drain rate per second", default=2)
|
||||
ap.add_argument("-n", type=float, help="queue capacity", default=3)
|
||||
ap.add_argument("-m", type=float, help="queue fill line", default=3)
|
||||
ap.add_argument("-r", type=float, help="drain rate per second", default=2)
|
||||
ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt")
|
||||
return ap.parse_args()
|
||||
|
||||
|
|
@ -65,9 +65,10 @@ class Bucket():
|
|||
self.CB = CB
|
||||
self.__last_pop = 0
|
||||
self.__last_state = False
|
||||
self.__last_push = None
|
||||
|
||||
def push(self):
|
||||
result = self.__push_c(1)
|
||||
result = self.__push()
|
||||
self.__cb()
|
||||
return result
|
||||
|
||||
|
|
@ -97,10 +98,15 @@ class Bucket():
|
|||
def state(self):
|
||||
return self.__last_state
|
||||
|
||||
def __push_c(self, c):
|
||||
def __push(self):
|
||||
self.__pop()
|
||||
c = 1
|
||||
now = self.__now()
|
||||
if self.__last_push:
|
||||
c = min([now - self.__last_push, 1])
|
||||
if self.q+c > self.N:
|
||||
return False
|
||||
self.__last_push = now
|
||||
self.q += c
|
||||
return True
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ python3 ./testdata/rand_0_n_weighted_stream.py \
|
|||
-w 3 \
|
||||
| peek \
|
||||
| python3 ./stream_to_state.py \
|
||||
-n 7 \
|
||||
-m 6 \
|
||||
-r 6
|
||||
-n 1 \
|
||||
-m .25 \
|
||||
-r .3
|
||||
|
|
|
|||
Loading…
Reference in New Issue