BenchmarkTransactionMarshal measures JSON serialization overhead
(b *testing.B)
| 136 | |
| 137 | // BenchmarkTransactionMarshal measures JSON serialization overhead |
| 138 | func BenchmarkTransactionMarshal(b *testing.B) { |
| 139 | txn := createTestTransaction("source-001", "dest-001", "ref-001", 100.00) |
| 140 | txn.TransactionID = "txn-benchmark-001" |
| 141 | txn.CreatedAt = time.Now() |
| 142 | txn.MetaData = map[string]interface{}{ |
| 143 | "order_id": "order-12345", |
| 144 | "customer_id": "cust-67890", |
| 145 | "description": "Payment for services", |
| 146 | } |
| 147 | |
| 148 | b.ResetTimer() |
| 149 | for i := 0; i < b.N; i++ { |
| 150 | _, err := json.Marshal(txn) |
| 151 | if err != nil { |
| 152 | b.Fatal(err) |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // BenchmarkTransactionUnmarshal measures JSON deserialization overhead |
| 158 | func BenchmarkTransactionUnmarshal(b *testing.B) { |
nothing calls this directly
no test coverage detected