11from abc import ABC , abstractmethod
22from dataclasses import dataclass
33from enum import Enum
4- from typing import Optional , Union
4+ from typing import List , Optional , Union
55
66import numpy
77
1212 "ProfileGenerationModes" ,
1313 "Profile" ,
1414 "ProfileGenerator" ,
15- "SingleProfileGenerator " ,
15+ "MultiProfileGenerator " ,
1616 "SweepProfileGenerator" ,
1717]
1818
1919
2020class ProfileGenerationModes (Enum ):
21- SINGLE = "single "
21+ MULTI = "multi "
2222 SWEEP = "sweep"
2323
2424
@@ -61,25 +61,24 @@ def next_profile(
6161 pass
6262
6363
64- @ProfileGenerator .register_generator (ProfileGenerationModes .SINGLE )
65- class SingleProfileGenerator (ProfileGenerator ):
66- def __init__ (self , rate : float , rate_type : str , ** kwargs ):
67- super ().__init__ (ProfileGenerationModes .SINGLE )
68- self ._rate = rate
64+ @ProfileGenerator .register_generator (ProfileGenerationModes .MULTI )
65+ class MultiProfileGenerator (ProfileGenerator ):
66+ def __init__ (self , rate : List [float ], rate_type : str , ** kwargs ):
67+ super ().__init__ (ProfileGenerationModes .MULTI )
68+ self ._rates = rate
69+ self ._rate_index = 0
6970 self ._rate_type = rate_type
7071 self ._generated = False
7172
7273 def next_profile (
7374 self , current_report : TextGenerationBenchmarkReport
7475 ) -> Optional [Profile ]:
75- if self ._generated :
76+ if self ._rate_index >= len ( self . _rates ) :
7677 return None
7778
78- self ._generated = True
79-
8079 if self ._rate_type == "constant" :
8180 return Profile (
82- load_gen_mode = LoadGenerationModes .CONSTANT , load_gen_rate = self ._rate
81+ load_gen_mode = LoadGenerationModes .CONSTANT , load_gen_rate = self ._rates [ self . _rate_index ]
8382 )
8483
8584 if self ._rate_type == "synchronous" :
@@ -89,7 +88,7 @@ def next_profile(
8988
9089 if self ._rate_type == "poisson" :
9190 return Profile (
92- load_gen_mode = LoadGenerationModes .POISSON , load_gen_rate = self ._rate
91+ load_gen_mode = LoadGenerationModes .POISSON , load_gen_rate = self ._rates [ self . _rate_index ]
9392 )
9493
9594 raise ValueError (f"Invalid rate type: { self ._rate_type } " )
@@ -151,4 +150,4 @@ def next_profile(
151150 load_gen_mode = LoadGenerationModes .CONSTANT , load_gen_rate = rate
152151 )
153152
154- return None
153+ return None
0 commit comments