Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of concatenate operator #292

Merged
merged 2 commits into from
Aug 25, 2024
Merged

Addition of concatenate operator #292

merged 2 commits into from
Aug 25, 2024

Conversation

AlexisDrogoul
Copy link
Member

Takes a list of strings in parameter and produces the string resulting from their concatenation

Takes a list of strings in parameter and produces the string resulting from their concatenation
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Health Quality Gates: OK

Change in average Code Health of affected files: +0.00 (7.11 -> 7.11)

  • Improving Code Health: 2 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Health Quality Gates: OK

Change in average Code Health of affected files: +0.00 (7.11 -> 7.11)

  • Improving Code Health: 2 findings(s) ✅

View detailed results in CodeScene

@@ -10,19 +10,20 @@
package gama.gaml.operators;

import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Getting better: Primitive Obsession
The ratio of primitive types in function arguments decreases from 85.19% to 79.66%, threshold = 30.0%

@@ -10,19 +10,20 @@
package gama.gaml.operators;

import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Getting better: String Heavy Function Arguments
The ratio of strings in function arguments decreases from 72.22% to 67.80%, threshold = 39.0%

@lesquoyb
Copy link
Contributor

It is indeed way more efficient to save big files as demonstrated by this example model:

model CONCAT

global{
	
	int nb_concat <- 10000;
	
	float seed <- 3.14;
	string f <- "file.txt";
	
	init {
		save "" to:f rewrite:true;	
	}
	
	reflex eval {		
		do save_directly;
		do optimized_save_directly;
		do concat_first;
		do concat_ope;
		do save_list;
	}
	
	action concat_first{
		benchmark message:"\nconcat string" repeat:10 {
			string s <- "";
			loop i from:0 to:nb_concat{
				s <- s + "" + rnd(0, 9);
			}
			save s to:f format:"txt";
		}
	}
	
	action save_directly {
		benchmark message:"\nsave directly" repeat:10 {
			loop i from:0 to:nb_concat{
				save "" + rnd(0, 9) to:f rewrite:false format:"txt";
			}
		}
	}
	
	action optimized_save_directly {
		benchmark message:"\noptimized save directly" repeat:10 {
			loop i from:0 to:nb_concat{
				save "" + rnd(0, 9) to:f rewrite:false format:"txt" buffering:"per_simulation";
			}
		}
	}
	
	action save_list{
		benchmark message:"\nsave list" repeat:10 {
			list<string> l;
			loop i from:0 to:nb_concat{
				l <+  "" + rnd(0, 9);
			}
			loop i over:l{
				save i to:f format:"txt" buffering:"per_simulation";				
			}
		}
	}
	
	action concat_ope {
		benchmark message:"\nconcatenate operator" repeat:10 {
			list<string> l;
			loop i from:0 to:nb_concat{
				l <+  "" + rnd(0, 9);
			}
			save concatenate(l) to:f format:"txt";
		}
	}
}

experiment b;

@lesquoyb lesquoyb merged commit e38a76b into 2024-06 Aug 25, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants