fabricedesre / cc3200-rs

Getting Rust to run on a TI cc3200
Mozilla Public License 2.0
7 stars 2 forks source link

Add test file to figure out println! formatting stack usage #38

Closed dhylands closed 6 years ago

dhylands commented 7 years ago

I get these results:

x
1
1.2
1.2.3
1.2.3.4
1.2
1.2 3.4
1.2 3.4 5.6
1.2 3.4 5.6 7.8
    null:     0
println!:   648
   int 1:   176
   int 2:    32
   int 3:    40
   int 4:    40
 float 1:  1464
 float 2:    48
 float 3:    40
 float 4:   112
fabricedesre commented 7 years ago

Cool! You could also add something to format floats, like: println!("{:.*}", 2, 1.234567);

dhylands commented 7 years ago

The current code uses {:.1} but I'll try adding what you suggested and see how it performs

dhylands commented 7 years ago

Wow. I added these 2 functions:

fn test1f2() {
    let num1: f64 = 1.234;
    println!("{:.*}", 2, num1);
}

fn test2f2() {
    let num1: f64 = 1.234;
    let num2: f64 = 2.345;
    println!("{:.*} {:.*}", 2, num1, 2, num2);
}

test1f2 required 1504 bytes test2f2 required an additional 724 bytes Adding one more only needed 80 extra bytes.

dhylands commented 7 years ago

So that means test2f2 needed a total of 2900 bytes of stack space.

dhylands commented 6 years ago

Closing old PRs