-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from gama-platform/clean-buffering
- Loading branch information
Showing
14 changed files
with
129 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
gama.library/models/GAML Syntax/System/Buffering execution order.gaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Name: Bufferingexecutionorder | ||
* Based on the internal empty template. | ||
* Author: baptiste | ||
* Tags: | ||
*/ | ||
|
||
|
||
// This model presents the order of execution of different results you can obtain by using different buffering strategies. | ||
model Bufferingexecutionorder | ||
|
||
global { | ||
|
||
|
||
reflex at_cycle { | ||
write "at cycle " + cycle buffering:"per_cycle"; | ||
save "at cycle " + cycle to:"data.csv" header:false rewrite:false buffering:"per_cycle" format:"csv"; | ||
} | ||
|
||
reflex at_cycle2 { | ||
write "at cycle2 " + cycle + " should appear after 'at cycle "+ cycle+"' as it's asked in that order" buffering:"per_cycle"; | ||
save "at cycle2 " + cycle + " should appear after 'at cycle "+ cycle+"' as it's asked in that order" to:"data.csv" header:false rewrite:false buffering:"per_cycle" format:"csv"; | ||
} | ||
|
||
reflex no_buffering { | ||
write "at cycle " + cycle + " too, should appear before all the other, as it's executed right when the code is reached" buffering:"no_buffering"; | ||
save "at cycle " + cycle + " too, should appear before all the other, as it's executed right when the code is reached" rewrite:false to:"data.csv" header:false buffering:"no_buffering" format:"csv"; | ||
} | ||
|
||
reflex end_of_simulation { | ||
write "Run at cycle " + cycle + " but should only be visible once the simulation is killed." buffering:"per_simulation"; | ||
save "Run at cycle " + cycle + " but should be appended at the end of the file" to:"data.csv" header:false rewrite:false buffering:"per_simulation" format:"csv"; | ||
} | ||
|
||
reflex end_sim when:cycle=4{ | ||
do die; | ||
} | ||
|
||
} | ||
|
||
experiment a type:batch until:cycle=10 autorun:true{ | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
gama.library/models/GAML Syntax/System/Buffering performances.gaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Name: Buffering | ||
* Based on the internal empty template. | ||
* Author: baptiste | ||
* Tags: | ||
*/ | ||
|
||
|
||
// This model presents the difference in terms of performance between writing many times directly in a file | ||
// or using a buffering strategy to have all the writing requests grouped into one big at the end of the cycle | ||
// this benchmarking is not using the "benchmark" statement as we also want to include the time it takes for the | ||
// engine to actually write the files at the end of the cycle. | ||
model BufferingPerformances | ||
|
||
|
||
global{ | ||
|
||
int state <- 0; | ||
int nb_rep <- 10000; | ||
float start_time; | ||
|
||
reflex write_duration_buffered when:state=3{ | ||
write "Duration for buffered writing: " + (gama.machine_time - start_time) + "ms"; | ||
do pause; | ||
} | ||
|
||
reflex write_buffered when:state = 2 { | ||
start_time <- gama.machine_time; | ||
loop times:nb_rep{ | ||
save "some text\n" to:"someotherfile.txt" rewrite:false buffering:"per_cycle" format:"txt"; | ||
} | ||
state <- 3; | ||
} | ||
|
||
reflex write_duration_direct when:state = 1 { | ||
write "Duration for direct writing: " + (gama.machine_time - start_time) + "ms"; | ||
state <- 2; | ||
} | ||
|
||
|
||
reflex write_directly when:state=0{ | ||
start_time <- gama.machine_time; | ||
loop times:nb_rep{ | ||
save "some text\n" to:"somefile.txt" rewrite:false buffering:"no_buffering" format:"txt"; | ||
} | ||
state <- 1; | ||
} | ||
|
||
} | ||
|
||
experiment compare; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters