1
0
mirror of https://gitlab.com/Anson-Projects/anson-stuff/Go-v-Rust-Quicksort.git synced 2025-06-15 13:46:40 +00:00

generated dataset, cant commit due to size

This commit is contained in:
Anson Biggs 2022-04-01 13:45:28 -07:00
parent 364bcb0f88
commit a24ad4a2d1
3 changed files with 72 additions and 3 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
target/
debug/
rust/Cargo.lock
rust/Cargo.lock
data_generation/Cargo.lock
data/

View File

@ -0,0 +1,67 @@
use rand::distributions::{Distribution, Uniform};
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::fs::File;
use std::io::Write;
fn main() {
{
let mut nums = (0..(50e3 as usize)).collect::<Vec<usize>>();
nums.shuffle(&mut thread_rng());
let num_str = nums
.iter()
.map(|n| n.to_string())
.collect::<Vec<String>>()
.join("\n");
let mut fp = File::create("../data/perm50e3.txt").expect("unable to create file");
fp.write_all(num_str.as_bytes()).expect("failed to write");
}
{
let mut nums = (0..(50e6 as usize)).collect::<Vec<usize>>();
nums.shuffle(&mut thread_rng());
let num_str = nums
.iter()
.map(|n| n.to_string())
.collect::<Vec<String>>()
.join("\n");
let mut fp = File::create("../data/perm50e6.txt").expect("unable to create file");
fp.write_all(num_str.as_bytes()).expect("failed to write");
}
{
let nums: Vec<i32> = Uniform::from(0..1_000_000_000)
.sample_iter(&mut thread_rng())
.take(50e6 as usize)
.collect();
let num_str = nums
.iter()
.map(|n| n.to_string())
.collect::<Vec<String>>()
.join("\n");
let mut fp = File::create("../data/billion50e6.txt").expect("unable to create file");
fp.write_all(num_str.as_bytes()).expect("failed to write");
}
{
let nums: Vec<f32> = Uniform::from(0.0..10.0)
.sample_iter(&mut thread_rng())
.take(50e3 as usize)
.collect();
let num_str = nums
.iter()
.map(|n| n.to_string())
.collect::<Vec<String>>()
.join("\n");
let mut fp = File::create("../data/floats50e3.txt").expect("unable to create file");
fp.write_all(num_str.as_bytes()).expect("failed to write");
}
}

View File

@ -89,7 +89,7 @@ func Qsort(s []int) {
func main() {
sortSize := 1000000
sortSize := 50000000
// MAXGOROUTINES := 1
unsorted := make([]int, 0, sortSize)
@ -103,7 +103,7 @@ func main() {
// MAXGOROUTINES = 1
start = time.Now()
unsorted = rand.Perm(sortSize)
// unsorted = rand.Perm(sortSize)
Cqsort(unsorted, 1)
duration = time.Since(start)