There is a pivot table spreadsheet on the openSTA site which allows you to work with timers. I wanted to compare that with a required result and then place "Pass" or "Fail" in the column depending on the result and then have "Fail" in red to highlight it.
You could of course use VBA but that requires a bit of programming skill.
The fist part is easy - just use the formula:
=IF(H1>K1,"Fail","Pass")
where H1 is the openSTA timer result and K1 is the required result.
The second part is done via selecting the "Pass" / "Fail" column and then right-click / Format / Conditional Formatting.
The condition is "Cell value is equal to "Fail"", then click on the "Format" button and select the red colour.
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Friday, September 05, 2008
openSTA : Creating random variables
I've been involved with openSTA testing lately and will blog on some things I learned.
One thing I needed to do was to run some tests on a web service that creates files. Each file had to be a different name.
and then in the web service, set the title to:
'Doc name '+ C_FC + C_TIMEVAL + '.doc
Enjoy!
One thing I needed to do was to run some tests on a web service that creates files. Each file had to be a different name.
INTEGER FILECOUNT, SCRIPT
INTEGER TIMEVAL
CHARACTER*10 C_FC
CHARACTER*10 C_TIMEVAL
...
ACQUIRE TEST-WIDE MUTEX "FC"
SET FILECOUNT = FILECOUNT + 1
CONVERT FILECOUNT TO C_FC
RELEASE TEST-WIDE MUTEX "FC"
ACQUIRE TEST-WIDE MUTEX "DocID"
LOAD TIME into TIMEVAL
!Ensure that the time provides 7 digits
SET TIMEVAL = TIMEVAL + 1000000
CONVERT TIMEVAL TO C_TIMEVAL
RELEASE TEST-WIDE MUTEX "DocID"
and then in the web service, set the title to:
'Doc name '+ C_FC + C_TIMEVAL + '.doc
Enjoy!
Wednesday, August 20, 2008
openSTA : Test hangs
Found an annoying problem with the Test box. When I changed a parameter, the whole application just froze - no error messages, nothing.
I eventually figured out that this was because the test file was R/O! Removing that attribute fixed the problem.
Enjoy!
I eventually figured out that this was because the test file was R/O! Removing that attribute fixed the problem.
Enjoy!
Monday, July 28, 2008
C# : Reading a binary file
I needed to read a file into a buffer for subsequent encoding.
Made the mistake of usuing TextReader which of course has issues becaise the EOF could be anywhere for a bionary file. Also you don't know how big the file is and you don't want to use Peek and read one character at a time.
Came up with the following:
Enjoy!
Made the mistake of usuing TextReader which of course has issues becaise the EOF could be anywhere for a bionary file. Also you don't know how big the file is and you don't want to use Peek and read one character at a time.
Came up with the following:
...
try
{
// Note: This is a binary file so can't use EOF
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] bArray = new byte[br.BaseStream.Length];
bArray = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
return bArray;
}
catch (Exception ex)
{
...
}
Enjoy!
Misc : Error 0X80070052 on USB Flash Drives
I came across this at the weekend.
Trying to copy some files from a DVD to a flash drive and kept getting this error.
Tried everything - reformatted etc. but no joy.
So Mr. Google to the rescue.
One link suggested that the problem was that there is a limit to the number of files you can copy to the root directory of a USB drive.
Sounded suspect but made a folder under root and then copied the files to the folder.
Suddenly everything worked!
Amazing!
Enjoy!
Trying to copy some files from a DVD to a flash drive and kept getting this error.
Tried everything - reformatted etc. but no joy.
So Mr. Google to the rescue.
One link suggested that the problem was that there is a limit to the number of files you can copy to the root directory of a USB drive.
Sounded suspect but made a folder under root and then copied the files to the folder.
Suddenly everything worked!
Amazing!
Enjoy!
Monday, July 07, 2008
Eclipse : Compiling JVM 1.4 with Eclipse Europa
Eclipse Europa won't work with anything less than JVM 1.5.
But what happens if your client needs a Java 1.4 program? Do you have to download an earlier version of Eclipse?
Actually - no!
You can compile 1.4 programs inside the Europa 1.5 workspace.
Under "Windows - Preferences - Java - Installed JREs", you need to add the path to the 1.4 JVM.
Right click on the 1.4 project.
Under "Properties - Java Build Path - Libraries", ensure that the JRE System Library points to the 1.4 version.
Under "Properties - Java Compiler", click "Enable project specific settings". Set "Compiler compliance level" to 1.4.
That's it.
Enjoy!
But what happens if your client needs a Java 1.4 program? Do you have to download an earlier version of Eclipse?
Actually - no!
You can compile 1.4 programs inside the Europa 1.5 workspace.
Under "Windows - Preferences - Java - Installed JREs", you need to add the path to the 1.4 JVM.
Right click on the 1.4 project.
Under "Properties - Java Build Path - Libraries", ensure that the JRE System Library points to the 1.4 version.
Under "Properties - Java Compiler", click "Enable project specific settings". Set "Compiler compliance level" to 1.4.
That's it.
Enjoy!
Thursday, June 26, 2008
Java : Implementing the C# foreach
This is a common construct:
It's messy and in C# you can easily do this far more elegantly with the "foreach" command.
How do you do this in Java?
Use something like e.g. for Reflection fields:
Enjoy!
for (int i = 0; i < "object".length; i++)
{
}
It's messy and in C# you can easily do this far more elegantly with the "foreach" command.
How do you do this in Java?
Use something like e.g. for Reflection fields:
import java.lang.reflect.Field;
Field[] fields = "object".getClass().getDeclaredFields();
for (Field field : fields)
{
...
field[i].getName();
...
}
Enjoy!
Java : Iterating and printing out elements of objects
It's a common problem.
You have an object aa with variables bb, cc and dd and for logging and for debugging purposes, you want to print out the current values of all three so you have:
which gets tedious when it's a large object.
Reflection to the rescue!
Note that if the variables in the object are declared as "private", this code will throw an exception. Hence the:
setAccessible(true);
method which overrides this.
Enjoy!
You have an object aa with variables bb, cc and dd and for logging and for debugging purposes, you want to print out the current values of all three so you have:
System.out.println ("value of bb is " + aa.bb);
System.out.println ("value of cc is " + aa.cc);
...
which gets tedious when it's a large object.
Reflection to the rescue!
import java.lang.reflect.Field;
Field[] fields = aa.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++)
{
try
{
fields[i].setAccessible(true);
System.out.println (fields[i].getName() + " = " + fields[i].get(xicmd));
}
catch (Exception ex)
{
System.out.println ("Reflection exception = " + ex.getMessage());
}
}
Note that if the variables in the object are declared as "private", this code will throw an exception. Hence the:
setAccessible(true);
method which overrides this.
Enjoy!
Tuesday, June 24, 2008
.NET : Timing averages
Following on from my previous post about TimeSpan, I needed to do some performance testing and calculate the average time each call took.
This was for a Windows Form project.
The "Application.DoEvents();" is to allow Windows some time to update the counts on the screen.
Enjoy!
This was for a Windows Form project.
for (int i = 0; i < iterations; i++)
{
DateTime startTime;
DateTime endTime;
int iterations;
int alteredIterations = 0;
TimeSpan total = new TimeSpan(0);
TimeSpan average = new TimeSpan(0);
alteredIterations = i + 1;
startTime = DateTime.Now;
... some method ...
endTime = DateTime.Now;
TimeSpan duration = endTime - startTime;
txtDuration.Text = duration.ToString();
total = total + duration;
average = TimeSpan.FromMilliseconds(total.TotalMilliseconds / alteredIterations);
txtAverage.Text = average.ToString();
Application.DoEvents();
}
The "Application.DoEvents();" is to allow Windows some time to update the counts on the screen.
Enjoy!
C# : Calculating timing differences
I needed to put some timings in my program. So I need to get a start time, an end time and then calculate the difference between them. TimeSpan to the rescue.
Enjoy!
static public DateTime startTime;
static public DateTime endTime;
TimeSpan duration = new TimeSpan();
startTime = DateTime.Now;
...
endTime = DateTime.Now;
duration = endTime - startTime;
"Print" ("Duration is " + duration);
Enjoy!
Eclipse : Starting with a different VM
For various reasons, a PC I use has Java 1.4 installed and the latest Eclipse Europa requires 1.5. I am unable to update the classpath, environment etc. so although 1.5 was installed, Eclipse would not find it.
The solution was to use the command line option:
C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.5.0_15\jre\bin\java.exe"
This forces Eclipse to load with the 1.5 VM.
I placed the command above in a shortcut so it's easily accessible from the desktop.
Enjoy!
The solution was to use the command line option:
C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.5.0_15\jre\bin\java.exe"
This forces Eclipse to load with the 1.5 VM.
I placed the command above in a shortcut so it's easily accessible from the desktop.
Enjoy!
Thursday, June 05, 2008
XP : Find that missing USB drive
I have a USB drive that simply will not load on one of my PC's.
The PC simply wouldn't recognise the drive no matter what I did.
So Mr. Google to the rescue.
I found the answer here.
The problem was "More than likely the cause is that Windows renamed the drive to a letter that is already in use. This will happen if you have several card readers, thumb drives or external hard drives attached. It will also happen if you are on a network and have mapped drives".
After following the advice, all was well.
Enjoy!
The PC simply wouldn't recognise the drive no matter what I did.
So Mr. Google to the rescue.
I found the answer here.
The problem was "More than likely the cause is that Windows renamed the drive to a letter that is already in use. This will happen if you have several card readers, thumb drives or external hard drives attached. It will also happen if you are on a network and have mapped drives".
After following the advice, all was well.
Enjoy!
Subscribe to:
Posts (Atom)