Coder Social home page Coder Social logo

Comments (6)

reaganmcf avatar reaganmcf commented on June 19, 2024 1

@max-niederman Awesome, let me know when you merge it into master and then I'll rewrite and finish my PR πŸ‘πŸ»

from ttyper.

reaganmcf avatar reaganmcf commented on June 19, 2024

I would like to work on this πŸ˜„

from ttyper.

reaganmcf avatar reaganmcf commented on June 19, 2024

I laid out the rough outline for this solution right now but it's a little hacky in my opinion. Storing the keys as [Fraction; 256] makes it really annoying to get the data, particularly sorting to get the worst keys. I feel like rewriting to use a HashMap<char, Fraction> would be much cleaner and more extendible. @max-niederman What do you think?

// get top 5 worst keys
let mut worst_key_display_str = String::from("Worst Keys:");
let mut key_and_cps_list: Vec<(char, f64)> = Vec::new();
for i in 0..256 {
    let temp = self.cps.per_key[i];
    let ascii_char = i as u8 as char;
    if temp.is_nan() || ascii_char == AsciiChar::BackSpace {
        continue;
    }
    key_and_cps_list.push((ascii_char, temp));
}
key_and_cps_list.sort_by(|a, b| {
    let f1 = a.1;
    let f2 = b.1;
    f1.partial_cmp(&f2).unwrap()
});
for key_and_cps_pair in key_and_cps_list[0..std::cmp::min(key_and_cps_list.len(), 5)].iter()
{
    worst_key_display_str = format!(
        "{}\n- '{}' at {:.2} cps",
        worst_key_display_str, key_and_cps_pair.0, key_and_cps_pair.1
    );
}
info_text.extend(Text::from(worst_key_display_str))

Below is an example of the output. I'm not really feeling this implementation with cps, and I'm going to use accuracy instead.

from ttyper.

max-niederman avatar max-niederman commented on June 19, 2024

Storing the keys as [Fraction; 256] makes it really annoying to get the data, particularly sorting to get the worst keys. I feel like rewriting to use a HashMap<char, Fraction> would be much cleaner and more extendible.

Yeah, it would probably be a good idea to rewrite the results to use a HashMap<char, T> not only for this feature, but also to better support unicode.

from ttyper.

max-niederman avatar max-niederman commented on June 19, 2024

Actually, now I think about it, we could just use a HashMap<KeyEvent, T>. @reaganmcf I'm going to work on switching to HashMap for the Results code.

from ttyper.

max-niederman avatar max-niederman commented on June 19, 2024

@reaganmcf I've merged the changes with master

from ttyper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.