MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / BenchmarkTransactionUnmarshal

Function BenchmarkTransactionUnmarshal

transaction_benchmark_test.go:158–178  ·  view source on GitHub ↗

BenchmarkTransactionUnmarshal measures JSON deserialization overhead

(b *testing.B)

Source from the content-addressed store, hash-verified

156
157// BenchmarkTransactionUnmarshal measures JSON deserialization overhead
158func 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
181func BenchmarkApplyTransactionToBalances(b *testing.B) {

Callers

nothing calls this directly

Calls 2

createTestTransactionFunction · 0.85
FatalMethod · 0.45

Tested by

no test coverage detected