Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created May 18, 2018 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmpwizard/f21b743db1d1d192de6513569c584dcd to your computer and use it in GitHub Desktop.
Save fmpwizard/f21b743db1d1d192de6513569c584dcd to your computer and use it in GitHub Desktop.
diego@diego-Precision-5520:~/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit$ go test -benchmem -bench BenchmarkMarkitExport --mongourl=127.0.0.1:27017 -memprofile=mem9.out
goos: linux
goarch: amd64
pkg: github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit
BenchmarkMarkitExport-8 300 3908632 ns/op 13436490 B/op 16003 allocs/op
PASS
ok github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit 1.659s
diego@diego-Precision-5520:~/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit$ go tool pprof --alloc_space mem9.out
File: markit.test
Type: alloc_space
Time: May 17, 2018 at 9:17pm (EDT)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) list BenchmarkMarkitExport
Total: 5.03GB
ROUTINE ======================== github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit.BenchmarkMarkitExport in /home/diego/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit/markit_test.go
4.94GB 5.03GB (flat, cum) 100% of Total
. . 108: }
. . 109:
. . 110: // Prepend the fake company ID to the ParentOrderID, to make sure not two
. . 111: // clients have conflicting values
. . 112: //z := companyFakeID[k] + "-" + trade.ParentOrderID
4.94GB 4.94GB 113: trade.ParentOrderID = companyFakeID[k] + "-" + trade.ParentOrderID
. . 114:
. 4MB 115: t1, t2 := tradeTimes(trade.TradeDate, trade.TradeTime1, trade.TradeTime2)
. . 116: id1, id2, id3, id4, id5, id6 := splitACMTradeID(trade.ACMTradeID)
. . 117:
. . 118: row := exportCSV{
. . 119: ClientID: companyFakeID[k],
. . 120: ParentOrderID: trade.ParentOrderID,
. . 121: //ParentOrderID: z,
. . 122: OrderID: trade.OrderID,
. 9MB 123: TradeDate: trade.TradeDate.Format("2006-01-02 15:04:05"),
. . 124: ExecutionTime: t1,
. . 125: ExecutionTime2: t2,
. . 126: TimeZone: "UTC",
. . 127: Side: trade.TransactionType,
. . 128: SecurityID1: trade.Ticker,
. . 129: SecurityID2: trade.Cusip,
. . 130: SecurityID3: trade.Sedol,
. . 131: SecurityID4: trade.Isin,
. . 132: SecurityName: trade.Security,
. 8.50MB 133: OrderQty: strconv.FormatFloat(trade.Quantity, 'f', -1, 64),
. 13.50MB 134: Price: strconv.FormatFloat(trade.Price, 'f', -1, 64),
. 15MB 135: NetAmount: strconv.FormatFloat(trade.Net, 'f', -1, 64),
. 9MB 136: Commission: strconv.FormatFloat(trade.Commission, 'f', -1, 64),
. . 137: LocalCurrency: trade.Currency,
. . 138: Broker: trade.BrokerageFirm,
. . 139: Venue: trade.Venue,
. . 140: AssetClassType: markitAssetClass(trade.SecurityType),
. . 141: PM: "",
. . 142: Trader: "",
. . 143: FXType: markitFXType(trade.SecurityType),
. . 144: Currency1: trade.CurrencyCurrency1,
. 13.50MB 145: CurrencyAmount1: strconv.FormatFloat(trade.CurrencyAmount1, 'f', -1, 64),
. . 146: Currency2: trade.CurrencyCurrency2,
. 13.50MB 147: CurrencyAmount2: strconv.FormatFloat(trade.CurrencyAmount2, 'f', -1, 64),
. . 148: AccountCodeName: "",
. . 149: ACMTradeID1: id1,
. . 150: ACMTradeID2: id2,
. . 151: ACMTradeID3: id3,
. . 152: ACMTradeID4: id4,
. . 153: ACMTradeID5: id5,
. . 154: ACMTradeID6: id6,
. . 155: }
. . 156:
. . 157: // key for our map is asset class + trade date with no time
. . 158: // so we can then generate a file for EQ + date and then FI + date
. 3.50MB 159: dateK := trade.TradeDate.Format("2006-01-02")
. . 160: if row.AssetClassType != "" {
. . 161: allRows[row.AssetClassType+"_"+dateK] = append(allRows[row.AssetClassType+"_"+dateK], row)
. . 162: } else {
. . 163: missingAssClass[trade.SecurityType] = true
. . 164: }
(pprof)
diego@diego-Precision-5520:~/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit$ go test -benchmem -bench BenchmarkMarkitExport --mongourl=127.0.0.1:27017 -memprofile=mem8.out
goos: linux
goarch: amd64
pkg: github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit
BenchmarkMarkitExport-8 1000 1467606 ns/op 288082 B/op 16003 allocs/op
PASS
ok github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit 1.668s
diego@diego-Precision-5520:~/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit$ go tool pprof --alloc_space mem8.out
Local symbolization failed for markit.test: open /tmp/go-build702366665/b001/markit.test: no such file or directory
Some binary filenames not available. Symbolization may be incomplete.
Try setting PPROF_BINARY_PATH to the search path for local binaries.
File: markit.test
Type: alloc_space
Time: May 17, 2018 at 9:16pm (EDT)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) list BenchmarkMarkitExport
Total: 294.56MB
ROUTINE ======================== github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit.BenchmarkMarkitExport in /home/diego/work/golang/src/github.com/ascendantcompliance/acm-go/cmd/blotterizer/markit/markit_test.go
34.50MB 294.01MB (flat, cum) 99.81% of Total
. . 107: companyFakeID[k] = bson.NewObjectId().Hex()
. . 108: }
. . 109:
. . 110: // Prepend the fake company ID to the ParentOrderID, to make sure not two
. . 111: // clients have conflicting values
34.50MB 34.50MB 112: z := companyFakeID[k] + "-" + trade.ParentOrderID
. . 113:
. 15MB 114: t1, t2 := tradeTimes(trade.TradeDate, trade.TradeTime1, trade.TradeTime2)
. . 115: id1, id2, id3, id4, id5, id6 := splitACMTradeID(trade.ACMTradeID)
. . 116:
. . 117: row := exportCSV{
. . 118: ClientID: companyFakeID[k],
. . 119: ParentOrderID: z,
. . 120: OrderID: trade.OrderID,
. 36MB 121: TradeDate: trade.TradeDate.Format("2006-01-02 15:04:05"),
. . 122: ExecutionTime: t1,
. . 123: ExecutionTime2: t2,
. . 124: TimeZone: "UTC",
. . 125: Side: trade.TransactionType,
. . 126: SecurityID1: trade.Ticker,
. . 127: SecurityID2: trade.Cusip,
. . 128: SecurityID3: trade.Sedol,
. . 129: SecurityID4: trade.Isin,
. . 130: SecurityName: trade.Security,
. 35.50MB 131: OrderQty: strconv.FormatFloat(trade.Quantity, 'f', -1, 64),
. 32MB 132: Price: strconv.FormatFloat(trade.Price, 'f', -1, 64),
. 33.50MB 133: NetAmount: strconv.FormatFloat(trade.Net, 'f', -1, 64),
. 30.50MB 134: Commission: strconv.FormatFloat(trade.Commission, 'f', -1, 64),
. . 135: LocalCurrency: trade.Currency,
. . 136: Broker: trade.BrokerageFirm,
. . 137: Venue: trade.Venue,
. . 138: AssetClassType: markitAssetClass(trade.SecurityType),
. . 139: PM: "",
. . 140: Trader: "",
. . 141: FXType: markitFXType(trade.SecurityType),
. . 142: Currency1: trade.CurrencyCurrency1,
. 25MB 143: CurrencyAmount1: strconv.FormatFloat(trade.CurrencyAmount1, 'f', -1, 64),
. . 144: Currency2: trade.CurrencyCurrency2,
. 36.50MB 145: CurrencyAmount2: strconv.FormatFloat(trade.CurrencyAmount2, 'f', -1, 64),
. . 146: AccountCodeName: "",
. . 147: ACMTradeID1: id1,
. . 148: ACMTradeID2: id2,
. . 149: ACMTradeID3: id3,
. . 150: ACMTradeID4: id4,
. . 151: ACMTradeID5: id5,
. . 152: ACMTradeID6: id6,
. . 153: }
. . 154:
. . 155: // key for our map is asset class + trade date with no time
. . 156: // so we can then generate a file for EQ + date and then FI + date
. 15.50MB 157: dateK := trade.TradeDate.Format("2006-01-02")
. . 158: if row.AssetClassType != "" {
. . 159: allRows[row.AssetClassType+"_"+dateK] = append(allRows[row.AssetClassType+"_"+dateK], row)
. . 160: } else {
. . 161: missingAssClass[trade.SecurityType] = true
. . 162: }
(pprof)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment