more coverage
This commit is contained in:
1 parent
d27d2e8e45
commit
fdf09daf0f
19 files changed
+1518
-728
No files matched your search
@@ -118,8 +118,8 @@
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script>
|
||||
var data = {"files":[{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","bin2hex.rs"],"content":"use clap::{Arg, Command};\nuse std::fs::File;\nuse std::io;\nuse std::io::{BufReader, Read};\n\n#[derive(Debug)]\nstruct CliArgs {\n input: String,\n}\n\nfn main() {\n println!(\"Taxation is Theft!\");\n // Set up the command line arguments\n let matches = Command::new(\"my_program\")\n .about(\"Processes an input file and outputs it with a specified bit width\")\n .arg(\n Arg::new(\"input\")\n .help(\"The input file to process\")\n .required(true)\n .index(1),\n )\n .get_matches();\n\n // Parse the command-line arguments\n let args = CliArgs {\n input: matches.get_one::\u003cString\u003e(\"input\").unwrap().to_string(),\n };\n\n // Use the parsed arguments\n println!(\"Input file: {}\", args.input);\n\n // behave like a shift register and load each character from the file 1 by 1.\n let results = read_file_to_bools(\u0026args.input);\n for result in results.unwrap().bytes() {\n print!(\"0x{:02x}, \", result.unwrap());\n }\n}\nfn read_file_to_bools(file_path: \u0026str) -\u003e io::Result\u003cVec\u003cu8\u003e\u003e {\n // Open the file\n let file = File::open(file_path)?;\n let mut reader = BufReader::new(file);\n\n let mut bytes = Vec::new();\n reader.read_to_end(\u0026mut bytes)?;\n\n let mut output = Vec::new();\n let mut current_byte = 0u8;\n let mut bit_index = 0;\n\n for \u0026byte in \u0026bytes {\n // Convert ASCII character '1' or '0' to boolean, skip any other characters\n let bit = match byte {\n b'1' =\u003e true,\n b'0' =\u003e false,\n _ =\u003e continue, // Skip non-'1' or '0' characters\n };\n\n // Set the appropriate bit in the current byte\n if bit {\n current_byte |= 1 \u003c\u003c (7 - bit_index); // Set the bit at the correct position\n }\n\n bit_index += 1;\n\n // Once we have filled 8 bits, push the byte and reset\n if bit_index == 8 {\n output.push(current_byte);\n current_byte = 0;\n bit_index = 0;\n }\n }\n\n // If there are remaining bits, push the last byte (it will be partially filled)\n if bit_index \u003e 0 {\n output.push(current_byte);\n }\n\n Ok(output)\n}\n","traces":[{"line":11,"address":[1046272,1048170],"length":1,"stats":{"Line":0}},{"line":12,"address":[1046294],"length":1,"stats":{"Line":0}},{"line":14,"address":[1046600,1046675,1046351],"length":1,"stats":{"Line":0}},{"line":17,"address":[1046505,1046433],"length":1,"stats":{"Line":0}},{"line":26,"address":[1046863,1046688],"length":1,"stats":{"Line":0}},{"line":30,"address":[1046902,1046995],"length":1,"stats":{"Line":0}},{"line":33,"address":[1047072],"length":1,"stats":{"Line":0}},{"line":34,"address":[1047344,1047587,1047447],"length":1,"stats":{"Line":0}},{"line":35,"address":[1047842],"length":1,"stats":{"Line":0}},{"line":38,"address":[1049326,1049382,1048224],"length":1,"stats":{"Line":0}},{"line":40,"address":[1048257,1048355],"length":1,"stats":{"Line":0}},{"line":41,"address":[1048323],"length":1,"stats":{"Line":0}},{"line":43,"address":[1048434],"length":1,"stats":{"Line":0}},{"line":44,"address":[1048494,1048562,1048656],"length":1,"stats":{"Line":0}},{"line":46,"address":[1048644],"length":1,"stats":{"Line":0}},{"line":47,"address":[1048689],"length":1,"stats":{"Line":0}},{"line":48,"address":[1048697],"length":1,"stats":{"Line":0}},{"line":50,"address":[1048716,1048787,1048881],"length":1,"stats":{"Line":0}},{"line":52,"address":[1048902],"length":1,"stats":{"Line":0}},{"line":53,"address":[1049077],"length":1,"stats":{"Line":0}},{"line":54,"address":[1049087],"length":1,"stats":{"Line":0}},{"line":59,"address":[1049095,1049204],"length":1,"stats":{"Line":0}},{"line":60,"address":[1049125,1049206],"length":1,"stats":{"Line":0}},{"line":63,"address":[1049228,1049250,1049105],"length":1,"stats":{"Line":0}},{"line":66,"address":[1049235,1049321],"length":1,"stats":{"Line":0}},{"line":67,"address":[1049268],"length":1,"stats":{"Line":0}},{"line":68,"address":[1049302],"length":1,"stats":{"Line":0}},{"line":69,"address":[1049310],"length":1,"stats":{"Line":0}},{"line":74,"address":[1048869],"length":1,"stats":{"Line":0}},{"line":75,"address":[1049005],"length":1,"stats":{"Line":0}},{"line":78,"address":[1048931],"length":1,"stats":{"Line":0}}],"covered":0,"coverable":31},{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","ch8asm.rs"],"content":"use gemma::chip8::util::InstructionUtil;\nuse gemma::chip8::{instructions::Chip8CpuInstructions, quirk_modes::QuirkMode};\nuse std::fs::{self, File};\nuse std::io::Write;\nuse clap::{Arg, Command};\n// Ch8Asm\n// Converts well formed CH8ASM.\n// no variables.\n// no labels.Line truncated
|
||||
var previousData = {"files":[]};
|
||||
var data = {"files":[{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","speedtest.rs"],"content":"use gemma::chip8::computer_manager::Chip8ComputerManager;\nuse std::fs::File;\nuse std::io::Read;\nuse std::ops::Add;\nuse std::path::Path;\nuse std::time::{Duration, Instant};\n\nconst ROM_ROOT: \u0026str = \"resources/roms\";\n\nfn main() {\n let mut x = Chip8ComputerManager::new();\n\n let mut buffer = Vec::new();\n let mut input_file =\n File::open(Path::new(\u0026(ROM_ROOT.to_string() + \"/mandelbrot_bench.ch8\"))).expect(\"derp\");\n input_file\n .read_to_end(\u0026mut buffer)\n .expect(\"unable to read file\");\n x.load_new_program_to_system_memory((\u0026*buffer).into());\n\n for _ in 0..10 {\n let start_time = Instant::now();\n let mut num_cycles = 0;\n // how many instructions in 10s.\n let end_time = start_time.add(Duration::from_secs(10));\n while Instant::now().le(\u0026end_time) {\n num_cycles += 1;\n x.step();\n }\n\n let num = num_cycles\n .to_string()\n .as_bytes()\n .rchunks(3)\n .rev()\n .map(std::str::from_utf8)\n .collect::\u003cResult\u003cVec\u003c\u0026str\u003e, _\u003e\u003e()\n .unwrap()\n .join(\",\"); // separator\n\n let num_ips = num_cycles / 1000000;\n println!(\"Completed at {num_ips} Mips. ({num})\");\n }\n}\n","traces":[{"line":10,"address":[458832,460780,460845],"length":1,"stats":{"Line":0}},{"line":11,"address":[458839],"length":1,"stats":{"Line":0}},{"line":13,"address":[458856],"length":1,"stats":{"Line":0}},{"line":14,"address":[458919,458991],"length":1,"stats":{"Line":0}},{"line":16,"address":[459251],"length":1,"stats":{"Line":0}},{"line":19,"address":[459336],"length":1,"stats":{"Line":0}},{"line":21,"address":[459436],"length":1,"stats":{"Line":0}},{"line":22,"address":[459589,459671],"length":1,"stats":{"Line":0}},{"line":23,"address":[459700],"length":1,"stats":{"Line":0}},{"line":25,"address":[459716],"length":1,"stats":{"Line":0}},{"line":26,"address":[459794],"length":1,"stats":{"Line":0}},{"line":27,"address":[460819,459898,460793],"length":1,"stats":{"Line":0}},{"line":28,"address":[460800,460840],"length":1,"stats":{"Line":0}},{"line":31,"address":[459891,460323,459933,460024,460390],"length":1,"stats":{"Line":0}},{"line":41,"address":[460537,460626],"length":1,"stats":{"Line":0}},{"line":42,"address":[460599,460646],"length":1,"stats":{"Line":0}}],"covered":0,"coverable":16},{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","testcompression.rs"],"content":"use std::fs;\nuse std::fs::File;\nuse clap::{Parser, Subcommand};\nuse flate2::{write::{GzEncoder, GzDecoder}, Compression};\nuse std::io::{Cursor, Read, Write};\nuse std::path::PathBuf;\nuse std::io::prelude::*;\n\n#[derive(Parser)]\n#[command(author, version, about = \"Compress or decompress a string\", long_about = None)]\nstruct Cli {\n /// Subcommand: either 'compress' or 'decompress'\n #[command(subcommand)]\n command: Commands,\n}\n\n#[derive(Subcommand)]\nenum Commands {\n /// Compress the input string\n Compress {\n /// The string to compress\n input: String,\n },\n /// Decompress the input string (must be compressed format)\n Decompress {\n /// The compressed string to decompress, in hex format\n input: String,\n },\n CompressFile {\n input: PathBuf\n },\n DecompressFile {\n input: PathBuf\n }\n}\n\nfn compress_string(input: \u0026str) -\u003e Vec\u003cu8\u003e {\n let mut encoder = GzEncoder::new(Vec::new(), Compression::default());\n encoder.write_all(input.as_bytes()).expect(\"Compression failed\");\n encoder.finish().expect(\"Failed to finish compression\")\n}\n\nfn decompress_string(input: \u0026[u8]) -\u003e String {\n let mut decoder = GzDecoder::new(Vec::new());\n decoder.write_all(input).expect(\"Decompression failed\");\n let decompressed_data = decoder.finish().expect(\"Failed to finish decompression\");\n String::from_utf8(decompressed_data).expect(\"Invalid UTF-8\")\n}\n\nfn compress_file(input_path: \u0026PathBuf) {\n let target_file_name = format!(\"{}.tflt\", input_path.display());\n println!(\"TARGET_FILE_NAME: {}\", target_file_name);\n let input_data = fs::read(input_path).expect(\"Failed to read input file\");\n let mut encoder = GzEncoder::new(Vec::new(), Compression::default());\n encoder.write_all(\u0026input_data).expect(\"Compression failed\");\n let compressed_data = encoder.finish().expect(\"Failed to finish compression\");\n let target_file = File::create(target_file_name);\n target_file.unwrap().write_all(\u0026compressed_data).unwrap()\n}\n\nfn decompress_file(input_path: \u0026PathBuf) {\n let target_file_name = format!(\"{}.uncompressed\", input_path.dispLine truncated
|
||||
var previousData = {"files":[{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","speedtest.rs"],"content":"use gemma::chip8::computer_manager::Chip8ComputerManager;\nuse std::fs::File;\nuse std::io::Read;\nuse std::ops::Add;\nuse std::path::Path;\nuse std::time::{Duration, Instant};\n\nconst ROM_ROOT: \u0026str = \"resources/roms\";\n\nfn main() {\n let mut x = Chip8ComputerManager::new();\n\n let mut buffer = Vec::new();\n let mut input_file =\n File::open(Path::new(\u0026(ROM_ROOT.to_string() + \"/mandelbrot_bench.ch8\"))).expect(\"derp\");\n input_file\n .read_to_end(\u0026mut buffer)\n .expect(\"unable to read file\");\n x.load_new_program_to_system_memory((\u0026*buffer).into());\n\n for _ in 0..10 {\n let start_time = Instant::now();\n let mut num_cycles = 0;\n // how many instructions in 10s.\n let end_time = start_time.add(Duration::from_secs(10));\n while Instant::now().le(\u0026end_time) {\n num_cycles += 1;\n x.step();\n }\n\n let num = num_cycles\n .to_string()\n .as_bytes()\n .rchunks(3)\n .rev()\n .map(std::str::from_utf8)\n .collect::\u003cResult\u003cVec\u003c\u0026str\u003e, _\u003e\u003e()\n .unwrap()\n .join(\",\"); // separator\n\n let num_ips = num_cycles / 1000000;\n println!(\"Completed at {num_ips} Mips. ({num})\");\n }\n}\n","traces":[{"line":10,"address":[460780,460845,458832],"length":1,"stats":{"Line":0}},{"line":11,"address":[458839],"length":1,"stats":{"Line":0}},{"line":13,"address":[458856],"length":1,"stats":{"Line":0}},{"line":14,"address":[458919,458991],"length":1,"stats":{"Line":0}},{"line":16,"address":[459251],"length":1,"stats":{"Line":0}},{"line":19,"address":[459336],"length":1,"stats":{"Line":0}},{"line":21,"address":[459436],"length":1,"stats":{"Line":0}},{"line":22,"address":[459589,459671],"length":1,"stats":{"Line":0}},{"line":23,"address":[459700],"length":1,"stats":{"Line":0}},{"line":25,"address":[459716],"length":1,"stats":{"Line":0}},{"line":26,"address":[459794],"length":1,"stats":{"Line":0}},{"line":27,"address":[459898,460793,460819],"length":1,"stats":{"Line":0}},{"line":28,"address":[460800,460840],"length":1,"stats":{"Line":0}},{"line":31,"address":[459933,460390,459891,460323,460024],"length":1,"stats":{"Line":0}},{"line":41,"address":[460537,460626],"length":1,"stats":{"Line":0}},{"line":42,"address":[460599,460646],"length":1,"stats":{"Line":0}}],"covered":0,"coverable":16},{"path":["/","home","tmerritt","Projects","trevors_chip8_toy","gemma","src","bin","testcompression.rs"],"content":"use std::fs;\nuse std::fs::File;\nuse clap::{Parser, Subcommand};\nuse flate2::{write::{GzEncoder, GzDecoder}, Compression};\nuse std::io::{Cursor, Read, Write};\nuse std::path::PathBuf;\nuse std::io::prelude::*;\n\n#[derive(Parser)]\n#[command(author, version, about = \"Compress or decompress a string\", long_about = None)]\nstruct Cli {\n /// Subcommand: either 'compress' or 'decompress'\n #[command(subcommand)]\n command: Commands,\n}\n\n#[derive(Subcommand)]\nenum Commands {\n /// Compress the input string\n Compress {\n /// The string to compress\n input: String,\n },\n /// Decompress the input string (must be compressed format)\n Decompress {\n /// The compressed string to decompress, in hex format\n input: String,\n },\n CompressFile {\n input: PathBuf\n },\n DecompressFile {\n input: PathBuf\n }\n}\n\nfn compress_string(input: \u0026str) -\u003e Vec\u003cu8\u003e {\n let mut encoder = GzEncoder::new(Vec::new(), Compression::default());\n encoder.write_all(input.as_bytes()).expect(\"Compression failed\");\n encoder.finish().expect(\"Failed to finish compression\")\n}\n\nfn decompress_string(input: \u0026[u8]) -\u003e String {\n let mut decoder = GzDecoder::new(Vec::new());\n decoder.write_all(input).expect(\"Decompression failed\");\n let decompressed_data = decoder.finish().expect(\"Failed to finish decompression\");\n String::from_utf8(decompressed_data).expect(\"Invalid UTF-8\")\n}\n\nfn compress_file(input_path: \u0026PathBuf) {\n let target_file_name = format!(\"{}.tflt\", input_path.display());\n println!(\"TARGET_FILE_NAME: {}\", target_file_name);\n let input_data = fs::read(input_path).expect(\"Failed to read input file\");\n let mut encoder = GzEncoder::new(Vec::new(), Compression::default());\n encoder.write_all(\u0026input_data).expect(\"Compression failed\");\n let compressed_data = encoder.finish().expect(\"Failed to finish compression\");\n let target_file = File::create(target_file_name);\n target_file.unwrap().write_all(\u0026compressed_data).unwrap()\n}\n\nfn decompress_file(input_path: \u0026PathBuf) {\n let target_file_name = format!(\"{}.uncompressed\", input_pLine truncated
|
||||
</script>
|
||||
<script crossorigin>/** @license React v16.13.1
|
||||
* react.production.min.js
|
||||
|
||||
Reference in new issue
Block a user