BenchmarkTransactionUnmarshal measures JSON deserialization overhead
(b *testing.B)
| 156 | |
| 157 | // BenchmarkTransactionUnmarshal measures JSON deserialization overhead |
| 158 | func BenchmarkTransactionUnmarshal(b *testing.B) { |
| 159 | txn := createTestTransaction("source-001", "dest-001", "ref-001", 100.00) |
| 160 | txn.TransactionID = "txn-benchmark-001" |
| 161 | txn.CreatedAt = time.Now() |
| 162 | txn.MetaData = map[string]interface{}{ |
| 163 | "order_id": "order-12345", |
| 164 | "customer_id": "cust-67890", |
| 165 | "description": "Payment for services", |
| 166 | } |
| 167 | |
| 168 | data, _ := json.Marshal(txn) |
| 169 | |
| 170 | b.ResetTimer() |
| 171 | for i := 0; i < b.N; i++ { |
| 172 | var result model.Transaction |
| 173 | err := json.Unmarshal(data, &result) |
| 174 | if err != nil { |
| 175 | b.Fatal(err) |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | // BenchmarkApplyTransactionToBalances measures in-memory balance calculation |
| 181 | func BenchmarkApplyTransactionToBalances(b *testing.B) { |
nothing calls this directly
no test coverage detected