Create a deeper YAML in nested.yaml
.
This requires heavily reducing the number of nodes since they are on average more indented. Leaving 5M nodes results in files larger than 1GB.
This commit is contained in:
parent
13923cd270
commit
3db16ce517
2 changed files with 3 additions and 2 deletions
|
@ -26,7 +26,7 @@ fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
println!("Generating nested.yaml");
|
println!("Generating nested.yaml");
|
||||||
let mut out = BufWriter::new(File::create(output_path.join("nested.yaml")).unwrap());
|
let mut out = BufWriter::new(File::create(output_path.join("nested.yaml")).unwrap());
|
||||||
nested::create_deep_object(&mut out, 5_000_000)?;
|
nested::create_deep_object(&mut out, 1_100_000)?;
|
||||||
|
|
||||||
println!("Generating small_objects.yaml");
|
println!("Generating small_objects.yaml");
|
||||||
let mut out = BufWriter::new(File::create(output_path.join("small_objects.yaml")).unwrap());
|
let mut out = BufWriter::new(File::create(output_path.join("small_objects.yaml")).unwrap());
|
||||||
|
|
|
@ -48,7 +48,8 @@ impl Tree {
|
||||||
fn push_node(&mut self) {
|
fn push_node(&mut self) {
|
||||||
let new_node = Node::new_rc_refcell();
|
let new_node = Node::new_rc_refcell();
|
||||||
let n_nodes = self.nodes.len();
|
let n_nodes = self.nodes.len();
|
||||||
let parent = &mut self.nodes[self.rng.gen_range(0..n_nodes)];
|
// Bias the nodes towards the end so that there is more nesting.
|
||||||
|
let parent = &mut self.nodes[self.rng.gen_range((3 * n_nodes / 4)..n_nodes)];
|
||||||
(**parent).borrow_mut().push_child(new_node.clone());
|
(**parent).borrow_mut().push_child(new_node.clone());
|
||||||
self.nodes.push(new_node);
|
self.nodes.push(new_node);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue