I recently ran into a classic case of "our code is using way more memory than it should". So I took my first dive into memory profiling Rust code. I read several posts about this, including the following
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * @return Retorna a cotação atual de um título específico do Tesouro Direto. | |
| * Fonte: https://www.tesourodireto.com.br/titulos/precos-e-taxas.htm | |
| **/ | |
| function TESOURODIRETO(bondName) { | |
| let srcURL = "https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondsinfo.json"; | |
| let jsondata = UrlFetchApp.fetch(srcURL); | |
| let parsedData = JSON.parse(jsondata.getContentText()).response; | |
| for(let bond of parsedData.TrsrBdTradgList) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Problem: | |
| // | |
| // 1. Generate a sequence of N distributed random floating point numbers in the range [A, B]. | |
| // 2. Split it into evenly spaced M subsequences (i.e., M bins of N/M items each). | |
| // 3. Make a histogram of each bin in parallel by counting from A to B how many fit in each b[i] in | |
| // a range of B/M. | |
| // 4. Merge all histograms back into one histogram of M. | |
| use rand::distributions::uniform::SampleUniform; | |
| use rand::Rng; |
https://llvm.org/docs/CommandGuide/FileCheck.html
Simple example:
; RUN: llvm-as < %s | llc -march=x86-64 | FileCheck %s