Is your feature request related to a problem? Please describe.
Regarding campaign definitions, mix_pct (percentage) forces the user to manually sum up each mix's percentage to get the right ratio, which can be error-prone and tedious in campaigns with lots of mixes.
Describe the solution you'd like
Use ratios instead.
- in
CampaignMixEntry and ResolvedMixEntry, change share_pct to ratio
- use unsigned ints instead of signed
Example:
mix_ratio_A = 2
mix_ratio_B = 1
total_tps = 100
Mix A would then produce 67 tps, and Mix B would produce 33, because A ≈ 2B.
Example:
mix_ratio_A = 1
mix_ratio_B = 1
mix_ratio_C = 1
mix_ratio_D = 1
total_tps = 100
Each mix would produce 25 tps.
Here's how I'd work out the final rate of each mix_ratio $\large m_i$ given total spam rate (tps/tpb) $\large t$:
$$\Large spamRate(m_i) = \frac{t * m_i}{\sum_{k=1}^n m_k}$$
or in code:
fn mix_spam_rate(ratio: u64, ratios: &[u64], total_rate: u64) -> u64 {
(total_rate * ratio) / ratios.iter().sum::<u64>()
}
Using unsigned ints in this formula sometimes creates conditions where the sum of the individual rates doesn't meet the total desired rate (e.g. you get 99 tps instead of 100 because of a round-down), but it gets close enough.
Using floating point integers at the intake (CampaignMixEntry) could solve this (allowing us to round more intelligently before casting to unsigned) but not sure it's worth the effort. Users can always just increase the total_rate a little bit to compensate if they need to exactly hit the target spam rate.
Is your feature request related to a problem? Please describe.
Regarding campaign definitions,
mix_pct(percentage) forces the user to manually sum up each mix's percentage to get the right ratio, which can be error-prone and tedious in campaigns with lots of mixes.Describe the solution you'd like
Use ratios instead.
CampaignMixEntryandResolvedMixEntry, changeshare_pcttoratioExample:
mix_ratio_A= 2mix_ratio_B= 1total_tps= 100Mix A would then produce 67 tps, and Mix B would produce 33, because A ≈ 2B.
Example:
mix_ratio_A= 1mix_ratio_B= 1mix_ratio_C= 1mix_ratio_D= 1total_tps= 100Each mix would produce 25 tps.
Here's how I'd work out the final rate of each mix_ratio$\large m_i$ given total spam rate (tps/tpb) $\large t$ :
$$\Large spamRate(m_i) = \frac{t * m_i}{\sum_{k=1}^n m_k}$$
or in code:
Using unsigned ints in this formula sometimes creates conditions where the sum of the individual rates doesn't meet the total desired rate (e.g. you get 99 tps instead of 100 because of a round-down), but it gets close enough.
Using floating point integers at the intake (
CampaignMixEntry) could solve this (allowing us to round more intelligently before casting to unsigned) but not sure it's worth the effort. Users can always just increase the total_rate a little bit to compensate if they need to exactly hit the target spam rate.