Having multiple gatling.conf files in a project - scala

I have 2 Gatling performance test simulations where each require slightly different config values. I was wondering if it's possible to have a separate gatling.conf file for each simulation and if it is possible, how would I link them to the simulations (potentially some code in the IDEPathHelper)?
Cheers,
Kris

Have you read the documentation?
It's pretty explicit you have to use the gatling.conf.file System property.

Related

How to implement a powershell functions library?

I recently worked on a project that we had to deployed using powershell scripts. We coded 2000 of lines, more or less, in different files. Some of them were dedicated to common methods but, after coding 500 lines for each one, it was hard to find what method to use or if it was necessary to implement a new one.
So, my question regards to what is the best way to implement a powershell functions library:
Is better having some files with lot of code than having a lot of files with few lines of code?
The answer from #MikeShepard is conceptually the way to go. Here are just a few implementation ideas to go along with it:
I have open-source libraries in a number of languages. My PowerShell API starts with the top-level being organized into different topics, as Mike Shepard suggested.
For those topics (modules) with more than one function (e.g. SvnSupport), each public function is in a separate file with its private support functions and variables, thereby increasing cohesion and decreasing coupling.
To wrap the collection of functions within a topic (module) together, you could enumerate them individually (either by dot-sourcing or including in the manifest, as #Thomas Lee suggested). But my preference is for a technique I picked up from Scott Muc. Use the following code as the entire contents of your .psm1 file and place each of your other functions in separate .ps1 files in the same directory.
Resolve-Path $PSScriptRoot\*.ps1 |
? { -not ($_.ProviderPath.Contains(".Tests.")) } |
% { . $_.ProviderPath }
There is actually quite a lot more to say about functions and modules; the interested reader might find my article Further Down the Rabbit Hole: PowerShell Modules and Encapsulation published on Simple-Talk.com a useful starting point.
You can create a Module where you can store all your script dedicated to common jobs.
I agree with #Christian's suggestion and use a module.
One tatic you might use is to break up the module into multiple scripts and include them all in the final module. You can either explicity dot-source them in a .PSM1 file, or specify the files in a manifest (.PSD1 file).
I tend to have multiple modules based on subject matter (loosely, nouns). For instance, if I had a bunch of functions dealing with MongoDB, I'd have a MongoDB module. That makes it easy to pull them into a session if I need them, but doesn't clutter every session with a bunch of functions that I rarely use. A consistent naming convention will make it easy to know what to import. For example, modMongoDB.psm1 would be an easy name to remember.
As a side note, in 3.0 module loading can be configured to be automatic so there's no need to preload a bunch of modules in your profile.

Environment properties files in scala project

Just starting to learn scala for a new project. Have got to the point where I would like to define different properties files for the different environments the app is going to run on, ideally in a similar way to Rails - very lightweight, just one different properties file per environment that is loaded based on its name. I don't really care if it's a java properties file, YML or scala code.
In the spirit of not reinventing the wheel I've been looking to see if there is some accepted standard Scala way of doing this but I can't find one, I've found a few similar but not identical questions here where people suggest using system properties in the startup script but this feels like it would end up being a nightmare.
I could obviously implement it if needs be but feels like the sort of thing that should already exist. So - does it?
I'm using sbt if that makes a difference.
I know of Configgy. Also, Akka/Play 2.0 will be using Config, which looks nice too. See blog about the latter.
Basically, Configgy has been used for a while now, but has been deprecated, while Config will be all-new. However, having Config as the default Typesafe Stack configuration tool will probably make it the preferred tool for that pretty fast.
I have written a Configgy replacement called Configrity. It can use different input formats (like YAML), it's immutable, supports functional patterns and uses type class to convert automatically the values to the desired type.
I have written BeeConfig, a replacement for java.util.Properties except that it is a Scala API and uses UTF-encoded configuration files. It supports string interpolation, chaining and a bunch of other features. But its main objective is simplicity.
Bitbucket | Blog post
Rick

How to access an array of structs in simulink?

I have the problem, that I have to access a funktion form a dll in matlab/Simulink in the rtw.
This should work with a s function, but I have the needed parameters in a array of structures organized.
The question is now how I can reach them when I want to call my DLL function?
Or is there a better way (e.g. level 2 Matlab files or something similar)?
The pure simulation (without RTW) worked pretty well with level 2 m files but I am not able to write a tlc file for compiling them. I did not find much on the net and the documentation only about C sources.
Thanks
Christian
For signals in Simulink, what you are asking for is an array of buses. There is similar support for using arrays of structs for parameters. For calling an external function, you might want to look at the legacy code tool. You might also be able to use the MATLAB function block to call your external dll.
In addition to what #MikeT says:
Generating code from Level 2 M-S-Functions is problematic. Read this: http://www.mathworks.co.uk/help/toolbox/simulink/sfg/f7-67622.html#brgscav-1
Also, M-S-functions are generally slow, because they run in the MATLAB interpreter: http://blogs.mathworks.com/seth/2010/10/28/tips-for-simulation-performance/
In the end I coded the problem in C and used an array where I defined to order of the elements. Then I wrote some interface functions to access this "virtual" struct.
This is not very good coding but the easiest way I have found and it is portable.
Thanks

random forest code review

I'm doing a research project on random forest algorithm. I have found numerous implementations of the algorithm but the main part of the code is often written in Fortran while I'm completely naive in it.
I have to edit the code, change the main parameters (like tree depth, num of feature variables, ...) and trace the algorithm's performance during each run.
Currently I'm using "Windows-Precompiled-RF_MexStandalone-v0.02-". The train and predict functions are matlab mex files and can not be opened or edited. Can anyone give me a piece of advice on what to do or is there a valid and completely matlab-based version of random forests.
I've read the randomforest-matlab carefully. The main training part unfortunately is a dll file. Through reading more, most of my wonders is now resolved. My question mainly was how to run several trees simultaneously.
Have you taken a look at these libraries?
Stochastic Bosque
randomforest-matlab
If you're doing a research project on it, the best thing is probably to implement the individual tree training yourself in C and then write Mex wrappers. I'd start with an ID3 tree (before attempting C4.5 for instance.) Then write the random forest code itself, which, once you write the tree code, isn't all that hard.
You'll:
learn a lot
be able to modify them as much as you like
eventually move on to exploring new areas with them
I've implemented them myself from scratch so I can help once you post some of your own code. But I don't think anybody on this site will write the code for you.
Will it take effort? Yes. Will you come out of it with more knowledge and ability than you had going in? Undoubtably.
There is a nice library in R called randomForest. It is based on the original implementation of Breiman in Fortran but it is now mainly recoded in C.
http://cran.r-project.org/web/packages/randomForest/index.html
The main parameters you talk about (tree depth, number of features to be tested, ...) are directly available.
Another library I would recommend is Weka. It is java based and lucid.Performance is slightly off though compared to R. The source code can be downloaded from http://www.cs.waikato.ac.nz/ml/weka/

testing strategies: generating a XML file

I'm writing a couple of classes that generate xml file. (Details probably not important at the moment).
I wondering the best testing strategy is.
I don't want to re-write the xml generation code just to compare the output, when I could write the file to disk and compare it at certain milestones (the xml spec won't change often, like once or twice every couple of years)
I'm more interested in testing the behaviour of the architecture instead of the getters & setters
Options that come to mind:
rebuilding the xml file in the testing environment and comparing the string representations
manually checking the result (writing to file, etc)
rebuilding the xml file in memory in the testing environment and comparing the in-memory elements.
Virtual Bonus if you know any libraries for C++ and/or Google Test.
Ideas?
Have you considered using XSD's and validating your XML to the XSD? You didn't mention if it was content or structure you were testing for (probably both).
If it validates, it will test the structure of the XML will conform to the required structure.
In the past I've approached this two ways:
Compare the xml file against the result stored as a string in the test file. This is easy to implement, and unless you are wanting to generate variations of the xml file for testing purposes, the string comparison method works fine.
In the case where you have a xml file writer and reader, you can compare the original with the round trip result.
I agree with you that you shouldn't replicate the logic to generate the file in the test function, just for the purpose of testing. Also, I would try to avoid the need to write to the file system -- this is unecessary dependence on the file system, and would probably result in slower running tests.
You might consider using XML Unit: http://xmlunit.sourceforge.net.
It provides JUnit extension classes which can be used to assert equality
of XML files.
You might consider an XML diff tool. There is a free one available on MSDN: XML Diff and Patch Tool.
I see you are looking for C++ tools. In that case, libxmldiff might be more suitable.