Repository: isucon/isucon11-qualify (language: go)

Issue:
[bench] keepPostingの高速化
#435 を解消した後の話

Sprintfと、appendが重い。
Sprintfは手でなんとかして、appendはそもそも捨てることが確定している要素はappendしないで良さそう
そもそも、チェーンにしないんだったら、GenerateNextConditionすらしなくて良いのか

![image](https://user-images.githubusercontent.com/15170167/126052789-373218f4-6f22-4876-a14a-01d611780aa8.png)
![image](https://user-images.githubusercontent.com/15170167/126052813-5242f044-beb5-4920-9611-990e3189c8e2.png)



Discussion / hints:
後は、makeでキャパシティを事前確保するとか
投げっぱなしにするとappendがやばい気がする
作った時間から逆算してcapacityを指定できるから最悪それをする
Sprintfはstringbuilderを使えばマシになりそう
post conditionの叩く頻度等諸々変わっているので、再度計測しないと意味がない
```
func (cond *IsuCondition) ConditionString() string {
	if cond.IsDirty {
		if cond.IsOverweight {
			if cond.IsBroken {
				return "is_dirty=true,is_overweight=true,is_broken=true"
			} else {
				return "is_dirty=true,is_overweight=true,is_broken=false"
			}
		} else {
			if cond.IsBroken {
				return "is_dirty=true,is_overweight=false,is_broken=true"
			} else {
				return "is_dirty=true,is_overweight=false,is_broken=false"
			}
		}
	} else {
		if cond.IsOverweight {
			if cond.IsBroken {
				return "is_dirty=false,is_overweight=true,is_broken=true"
			} else {
				return "is_dirty=false,is_overweight=true,is_broken=false"
			}
		} else {
			if cond.IsBroken {
				return "is_dirty=false,is_overweight=false,is_broken=true"
			} else {
				return "is_dirty=false,is_overweight=false,is_broken=false"
			}
		}
	}
}
```
↑Sprintfでしたくないという話

Fix patch:
diff --git a/bench/model/isuCondition.go b/bench/model/isuCondition.go
index 9f33a4978..cfc7f624f 100644
--- a/bench/model/isuCondition.go
+++ b/bench/model/isuCondition.go
@@ -387,3 +387,35 @@ func (iter *IsuConditionTreeSetIterator) Prev() *IsuCondition {
 	}
 	return max
 }
+
+func (cond *IsuCondition) ConditionString() string {
+	if cond.IsDirty {
+		if cond.IsOverweight {
+			if cond.IsBroken {
+				return "is_dirty=true,is_overweight=true,is_broken=true"
+			} else {
+				return "is_dirty=true,is_overweight=true,is_broken=false"
+			}
+		} else {
+			if cond.IsBroken {
+				return "is_dirty=true,is_overweight=false,is_broken=true"
+			} else {
+				return "is_dirty=true,is_overweight=false,is_broken=false"
+			}
+		}
+	} else {
+		if cond.IsOverweight {
+			if cond.IsBroken {
+				return "is_dirty=false,is_overweight=true,is_broken=true"
+			} else {
+				return "is_dirty=false,is_overweight=true,is_broken=false"
+			}
+		} else {
+			if cond.IsBroken {
+				return "is_dirty=false,is_overweight=false,is_broken=true"
+			} else {
+				return "is_dirty=false,is_overweight=false,is_broken=false"
+			}
+		}
+	}
+}
diff --git a/bench/scenario/posting.go b/bench/scenario/posting.go
index 95ab5e981..b717f7b82 100644
--- a/bench/scenario/posting.go
+++ b/bench/scenario/posting.go
@@ -108,11 +108,7 @@ func (s *Scenario) keepPosting(ctx context.Context, step *isucandar.BenchmarkSte
 			conditions = append(conditions, condition)
 			conditionsReq = append(conditionsReq, service.PostIsuConditionRequest{
 				IsSitting: condition.IsSitting,
-				Condition: fmt.Sprintf("is_dirty=%v,is_overweight=%v,is_broken=%v",
-					condition.IsDirty,
-					condition.IsOverweight,
-					condition.IsBroken,
-				),
+				Condition: condition.ConditionString(),
 				Message:   condition.Message,
 				Timestamp: condition.TimestampUnix,
 			})


Test patch: