Presentazione
Benvenuti sul mio sito !
Mi chiamo Danilo Berta e lavoro dal 1995 nel campo dello sviluppo software e relativa gestione dei processi IT, sia lato sviluppo che lato gestione del processo di qualità, con una marcata specializzazione nel campo del Software Testing. Il sito riporta il mio curriculum vitae dettagliato, l'elenco dei titoli di studi e certificazioni in mio possesso e le pubblicazioni. Nella sezione "Sviluppo Software, testing ... e altro" potete trovare un po' di informazioni che possono essere interessanti... e non solo aventi a che fare con il software; potete lasciare commenti, a patto di essere registrati, e potete contattarmi utilizzando il form contatto online. Il sito è appena agli inizi, quindi il materiale presente è scarso; in ogni caso, buon divertimento !
Cartesian Product with Groovy
In what follow a groovy script to perform cartesian product of variables A,B,C,.. each one with differnt values is presented. The script should be compared with the analog Python or C++ programs.
Following the code with all the comments inside.
#!/usr/bin/groovy /** * This is a simple groovy script calculating combinations of variables A,B,C,... written * in a file test.txt in the * following format: * * ########################## * # Example file test.txt * ########################## * * # Variable A * A:1,2,3 * * # Variable B * B:a,b,c * * # Variable C * C:11,12,13,14,15 * * # Variable D * D:aa,bb,cc * * # Variable E * E:a1,b1,c1,d1,d3,d4 * * The variable must be separated from the list of value with a colon ":", while * the list elements must be separated with a coma "," * * For example * A:1,2,3,4 * define the variable A that should get the values 1,2,3,4 * * The # char is used to insert comments in the file, where is also possible to * add how many blank lines as you want to improve readability. * * Programs must be called with: * * groovy ProdCart.groovy -f test.txt * * The output is printed on standard output and is possible to re-pipe it in file using * standard *ix (or windows) > and >> operators. * */ // Print out error if input parameters are not correct // Look at: http://www.javaworld.com/article/2074004/core-java/customizing-groovy-s-clibuilder-usage-statements.html def cli = new CliBuilder( usage: 'ProdCart -f fileName', header: '\nAvailable options (use -h for help):\n', footer: '\nInformation provided via above options is used to generate printed string.\n') //import org.apache.commons.cli.Option cli.with { h(longOpt: 'help', 'Usage Information', required: false) f(longOpt: 'file', 'File Name', args: 1, required: true) } def opt = cli.parse(args) if (!opt) return if (opt.h) cli.usage() // Variable declaration def inputFile = opt.f def cont = 0 def arrHeader = [] def arrItems = [ [] , [] ] def permutazioni = [ [] ] // Read the string in the input file File inFile = new File(inputFile) String[] arrLines = inFile.readLines() arrLines.each {line -> if(!line.startsWith("#") && !line.empty) { def arrHeaderItems = line.tokenize(":") arrHeader << arrHeaderItems[0] arrItems[cont] = arrHeaderItems[1].tokenize(",") cont += 1 } } // Load permutation array with arrItems arrItems.each {item -> permutazioni << item } // Print combinations with header println arrHeader.join(",\t") permutazioni.combinations().each { comb -> println comb.toString().replace(" ","").replace("[","").replace("]","").replace(",",",\t") }Following the downloadable code and example imput file
C++ and Binary Files
In what follows it's reported a simple C++ programs that write and read a long int and an int into a binary file. In the program list we do not manage error conditions, like file that does not exist, error on writing file, ... because out of scope for this short article, focused on reading and writing binary data on file using C++
#include <iostream> #include <fstream> #include <climits> #include <string> #include <bitset> using namespace std; int main() { // CONSTANT const std::string FILE_NAME = "file.bin"; // Variable declaration unsigned long lngNum = 0; unsigned int intNum = 0; // Notes on consolle cout << "Total sizeof: " << sizeof(lngNum) << " + " << sizeof(intNum) << endl; // ****************** // ** WRITING FILE ** // ****************** cout << "Writing binary file..." << endl; ofstream file_o (FILE_NAME, ios::binary); for (int i=0; i<16; ++i){ // Insert numbers starting from MAX ot the corresponding type lngNum = (ULONG_MAX-15) + i; //ULONG_MAX intNum = (UINT_MAX -15) + i; //UINT_MAX // Write binary file file_o.write (reinterpret_cast<const char *>(&lngNum), sizeof(lngNum)); file_o.write (reinterpret_cast<const char *>(&intNum), sizeof(intNum)); // Print out data cout << "lngNum decimal = " << lngNum << " - intNum decimal = " << intNum << endl; } // Closing file file_o.close (); // ****************** // ** READING FILE ** // ****************** lngNum = 0; // ... just to clear variable intNum = 0; cout << "Reading binary file..." << endl; ifstream file_i (FILE_NAME, ios::binary); if(file_i.is_open()){ // Cycle on file while(true){ // Read data into a long and int file_i.read(reinterpret_cast<char *>(&lngNum),sizeof(lngNum)); file_i.read(reinterpret_cast<char *>(&intNum),sizeof(intNum)); // Exit if EOF if(file_i.eof()) { break; } // Print out data cout << "lngNum = " << endl; cout << std::dec << "\t decimal = " << lngNum << endl; cout << std::hex << "\t hexadecimal = " << lngNum << endl; cout << std::oct << "\t octal = " << lngNum << endl; cout << "\t binary = " << std::bitset< sizeof(lngNum)*8 >( lngNum ) << endl; cout << "intNum = " << endl; cout << std::dec << "\t decimal = " << intNum << endl; cout << std::hex << "\t hexadecimal = " << intNum << endl; cout << std::oct << "\t octal = " << intNum << endl; cout << "\t binary = " << std::bitset< sizeof(intNum)*8 >( intNum ) << endl; cout << "******************************************************************************" << endl; } } // Closing file file_i.close (); return 0; }
In more details, in the first part (writing file) the two variables are written 16 times and we can think at the file as composed by sixteen “rows” each with two “columns” with the first having the “long int” value and the second having the “int” value.
In the second part (reading file) the two variables are read “line by line” and printed out.
Take care that a binary file cannot be subdivided by “lines” or “rows”. All bits 1/0 are in sequence, so thinking at it “by row” is just a virtual way to interpret it. With some little arrangement, the script should be useful to dump binary file in different format (if the standard tools xxd, hexdump, od, … and others that for sure exist and that I do not know are not “good enough” for you :-))) ).
The output is the following:
Total sizeof: 8 + 4 Writing binary file... lngNum decimal = 18446744073709551600 - intNum decimal = 4294967280 lngNum decimal = 18446744073709551601 - intNum decimal = 4294967281 lngNum decimal = 18446744073709551602 - intNum decimal = 4294967282 lngNum decimal = 18446744073709551603 - intNum decimal = 4294967283 lngNum decimal = 18446744073709551604 - intNum decimal = 4294967284 lngNum decimal = 18446744073709551605 - intNum decimal = 4294967285 lngNum decimal = 18446744073709551606 - intNum decimal = 4294967286 lngNum decimal = 18446744073709551607 - intNum decimal = 4294967287 lngNum decimal = 18446744073709551608 - intNum decimal = 4294967288 lngNum decimal = 18446744073709551609 - intNum decimal = 4294967289 lngNum decimal = 18446744073709551610 - intNum decimal = 4294967290 lngNum decimal = 18446744073709551611 - intNum decimal = 4294967291 lngNum decimal = 18446744073709551612 - intNum decimal = 4294967292 lngNum decimal = 18446744073709551613 - intNum decimal = 4294967293 lngNum decimal = 18446744073709551614 - intNum decimal = 4294967294 lngNum decimal = 18446744073709551615 - intNum decimal = 4294967295 Reading binary file... lngNum = decimal = 18446744073709551600 hexadecimal = fffffffffffffff0 octal = 1777777777777777777760 binary = 1111111111111111111111111111111111111111111111111111111111110000 intNum = decimal = 4294967280 hexadecimal = fffffff0 octal = 37777777760 binary = 11111111111111111111111111110000 ****************************************************************************** lngNum = decimal = 18446744073709551601 hexadecimal = fffffffffffffff1 octal = 1777777777777777777761 binary = 1111111111111111111111111111111111111111111111111111111111110001 intNum = decimal = 4294967281 hexadecimal = fffffff1 octal = 37777777761 binary = 11111111111111111111111111110001 ****************************************************************************** lngNum = decimal = 18446744073709551602 hexadecimal = fffffffffffffff2 octal = 1777777777777777777762 binary = 1111111111111111111111111111111111111111111111111111111111110010 intNum = decimal = 4294967282 hexadecimal = fffffff2 octal = 37777777762 binary = 11111111111111111111111111110010 ****************************************************************************** lngNum = decimal = 18446744073709551603 hexadecimal = fffffffffffffff3 octal = 1777777777777777777763 binary = 1111111111111111111111111111111111111111111111111111111111110011 intNum = decimal = 4294967283 hexadecimal = fffffff3 octal = 37777777763 binary = 11111111111111111111111111110011 ****************************************************************************** lngNum = decimal = 18446744073709551604 hexadecimal = fffffffffffffff4 octal = 1777777777777777777764 binary = 1111111111111111111111111111111111111111111111111111111111110100 intNum = decimal = 4294967284 hexadecimal = fffffff4 octal = 37777777764 binary = 11111111111111111111111111110100 ****************************************************************************** lngNum = decimal = 18446744073709551605 hexadecimal = fffffffffffffff5 octal = 1777777777777777777765 binary = 1111111111111111111111111111111111111111111111111111111111110101 intNum = decimal = 4294967285 hexadecimal = fffffff5 octal = 37777777765 binary = 11111111111111111111111111110101 ****************************************************************************** lngNum = decimal = 18446744073709551606 hexadecimal = fffffffffffffff6 octal = 1777777777777777777766 binary = 1111111111111111111111111111111111111111111111111111111111110110 intNum = decimal = 4294967286 hexadecimal = fffffff6 octal = 37777777766 binary = 11111111111111111111111111110110 ****************************************************************************** lngNum = decimal = 18446744073709551607 hexadecimal = fffffffffffffff7 octal = 1777777777777777777767 binary = 1111111111111111111111111111111111111111111111111111111111110111 intNum = decimal = 4294967287 hexadecimal = fffffff7 octal = 37777777767 binary = 11111111111111111111111111110111 ****************************************************************************** lngNum = decimal = 18446744073709551608 hexadecimal = fffffffffffffff8 octal = 1777777777777777777770 binary = 1111111111111111111111111111111111111111111111111111111111111000 intNum = decimal = 4294967288 hexadecimal = fffffff8 octal = 37777777770 binary = 11111111111111111111111111111000 ****************************************************************************** lngNum = decimal = 18446744073709551609 hexadecimal = fffffffffffffff9 octal = 1777777777777777777771 binary = 1111111111111111111111111111111111111111111111111111111111111001 intNum = decimal = 4294967289 hexadecimal = fffffff9 octal = 37777777771 binary = 11111111111111111111111111111001 ****************************************************************************** lngNum = decimal = 18446744073709551610 hexadecimal = fffffffffffffffa octal = 1777777777777777777772 binary = 1111111111111111111111111111111111111111111111111111111111111010 intNum = decimal = 4294967290 hexadecimal = fffffffa octal = 37777777772 binary = 11111111111111111111111111111010 ****************************************************************************** lngNum = decimal = 18446744073709551611 hexadecimal = fffffffffffffffb octal = 1777777777777777777773 binary = 1111111111111111111111111111111111111111111111111111111111111011 intNum = decimal = 4294967291 hexadecimal = fffffffb octal = 37777777773 binary = 11111111111111111111111111111011 ****************************************************************************** lngNum = decimal = 18446744073709551612 hexadecimal = fffffffffffffffc octal = 1777777777777777777774 binary = 1111111111111111111111111111111111111111111111111111111111111100 intNum = decimal = 4294967292 hexadecimal = fffffffc octal = 37777777774 binary = 11111111111111111111111111111100 ****************************************************************************** lngNum = decimal = 18446744073709551613 hexadecimal = fffffffffffffffd octal = 1777777777777777777775 binary = 1111111111111111111111111111111111111111111111111111111111111101 intNum = decimal = 4294967293 hexadecimal = fffffffd octal = 37777777775 binary = 11111111111111111111111111111101 ****************************************************************************** lngNum = decimal = 18446744073709551614 hexadecimal = fffffffffffffffe octal = 1777777777777777777776 binary = 1111111111111111111111111111111111111111111111111111111111111110 intNum = decimal = 4294967294 hexadecimal = fffffffe octal = 37777777776 binary = 11111111111111111111111111111110 ****************************************************************************** lngNum = decimal = 18446744073709551615 hexadecimal = ffffffffffffffff octal = 1777777777777777777777 binary = 1111111111111111111111111111111111111111111111111111111111111111 intNum = decimal = 4294967295 hexadecimal = ffffffff octal = 37777777777 binary = 11111111111111111111111111111111 ******************************************************************************
Regarding xxd this is a short script to convert binary data interpreted as exadecimal (the first 12 byte, but you can change as you want) in decimal.
xxd -c 12 -p -u file.bin > out.sh ; sed -i -e 's/^/echo "ibase=16;/' out.sh ; sed -i -e 's/$/" | bc/' out.sh ; chmod +x out.sh; ./out.sh ; rm out.sh
Quick Start Guide and Tutorial for IBM © Rational Performance Tester © – SOA (Web Service) Performance Test Projects
The document downloadable at the bottom of this article is a primer to let you start with the IBM© Rational Performance Tester© (in the following RPT) and just scratch the surface of the product; for more details I suggest to look at online IBM documentation or check-out the IBM© Redbooks© publications: (https://www.redbooks.ibm.com/).
The only prerequisite is to have installed on Windows a working copy of the trial version downloadable from IBM © web site: http://www.ibm.com/developerworks/downloads/r/rpt/.
In this tutorial we do not deal with platform installation that should be found in the IBM© Knowledge Center: http://www-01.ibm.com/support/knowledgecenter/ just search for product name.
In the guide we will use a public available web service: http://www.w3schools.com/webservices/tempconvert.asmx.
Here we do not want to assess in any way the performance and/or the availability and/or stability or any other characteristic of the program (web service) considered.
Using this guide you agree to not use the information here reported to offend and/or damage in any way the program (web service) and/or any other software/hardware considered. Any detrimental and/or illegal action you will perform will be your responsibility and the owner of the present document cannot be in any way prosecuted. The topics are:
- Prerequisites
- DISCLAIMER AND LICENSE NOTES
- Build the Test Script
- Add parameter’s values to Test
- Add Transaction
- Add Verification Points
- Build the Schedule
- Run the Performance Test
This document and only this document is available under “Public Domain”; license note below.
CC0 Summary: https://creativecommons.org/publicdomain/zero/1.0/
CC0 Legal Text: https://creativecommons.org/publicdomain/zero/1.0/legalcode
IBM©, Rational Performance Tester ©, WebSphere © and all other marks are a trademarks and /or registered trademark.
Using this guide you agree with all reported above.