Calculate elapsed time with VBS/PowerShell
I'm trying to calculate MDT task sequence execution time. What could be the best method for this? It can be PowerShell or VBS code.
Plan is to execute a script at the beginning of a task sequence that stores a start time in variable and at the end of task sequence execute another script that reads that start time from variable and calculates total time taken and saves it to another variable.
I have tried few VB scripts but I have had some odd results some times with them. We are using 24 hour clock and it might have caused some problems for my previous scripts.
I think you can enable monitoring and then validate from a console the elapsed time. It's a slow morning so I also wrote something that would work in powershell for fun -
param($start, $stop)
$file = $(get-date -f mmddyyyy) + '_timer.log'
$filepath = "$env:temp\$file"
function Start-Time {
if(test-path $filepath){
Remove-Item -path $filepath -force
else{
New-Item -ItemType File -Path $filepath
function Calculate-Time {
if(!(Test-Path $filepath)){
Write-Error "Calculate-Time: ERROR - Timer file was not found at path $filepath. Please validate you are running this script with the -start parameter before running with the -finish parameter."
else{
$fileinfo = gci $filepath
$stime = $fileinfo.CreationTime
$etime = (Get-Date)
$time = New-TimeSpan -start $stime -end $etime
return "Time from creation of file to finish is $time."
function Main{
if($start){
Start-Time | Out-Null
if($stop){
Calculate-Time | Out-Null
else{
return "Main: You must provide a parameter to use this tool. Parameters are -start to start the timer or -stop to end the timer and calculate time elapsed."
Main
You can modify filepath at the top to set where it saves the file. What it does is creates a file in the environment temp directory and then uses that file creation time against current date/time to give you a duration. Parameter -start creates
the file starting the timer and parameter -stop finds that file and calculates the difference in time between creation and current time. Either way I needed to get some powershell practice and maybe this will help you.
Ryan
Similar Messages
-
Calculate elapse time of a Java thread before execution
Hi,
I would like to enquire how can I calculate the elapse time of a Java thread BEFORE this thread is executiing or running.?
I wish to estimate the elapsed time of each Java thread before execution to better schedule these threads to run on multiple processors for load balancing testing.
Please help
-meileng-[You can grab the system time in the initiating thread immediately before calling start(), and as the first step in run() in the new thread.
However, this measurement is utterly meaningless, as it can vary between architectures or even between consecutive runs on the same box. Furthermore, even once a thread starts, it may do nothing more than that one grab-the-system-time instruction before it get swapped out for a theoretically unbounded amount of time.
By definition, if you spawn multiple threads in Java, you don't know or care which one get CPU time when, except as you control by syncing, sleep, wait, notify, notifyAll, and whatever control priorities give you. Additionally, you don't know when the OS will give your VM cycles, and on multi-CPU machines, you don't know how many CPUs it will get when it does get cycles. -
How to calculate elapsed time(including time and date)?
Hi all,
I want to realize a function that can calculate the elapsed time which include time and date.Below is my thought:get the current time and date and store it to a .txt file then using the latest time and date subtract the time and date stored in the .txt file.how can realize it using the simplest way?I'm using LV7.1.Hi Idragon,
you can do it like this.
Mike
Attachments:
DateTime.PNG 12 KB -
How to calculate elapsed time based on user input
I'm not sure what to do next in this program. Basically, I'm not sure exactly how to get the time to output accurately, as in what forumla I should be using.
This is the question:
What comes 13 hours after 4 o'clock? Create an ElaspedTimeCalculator application that prompts the user for a starting hour, whether it is am or pm, and the number of elapsed hours. The application then displays the time after that many hours have passed. Application output should look similar to:
Enter the starting hour: 7
Enter am or pm: pm
Enter the number of elapsed hours: 10
The time is: 5:00 amHere's the code I have so far:
import java.util.Scanner;
public class ElapsedTimeCalculator
public static void main(String[] args)
int starting_hour;
int starting_minutes; /*This is added in case the user wants to add minutes as well.*/
String am_or_pm;
int elapsed_hours;
int elasped_minutes;
int time_hours;
int time_minutes;
System.out.println("Welcome. This application will give you the time based on your input.");
System.out.println(" ");
Scanner input = new Scanner(System.in);
System.out.print("Enter the starting hour: ");
starting_hour = input.nextDouble();
System.out.print("Enter the starting minutes: ");
starting_minutes = input.nextDouble();
System.out.print("Enter either 'am' or pm': ");
am_or_pm = input.nextString();
System.out.print("Enter the number of elapsed hours: ");
elapsed_hours = input.nextDouble();
input.close();
time_hours =
time_minutes =
if(am_or_pm = "am" || am_or_pm = "a.m." || am_or_pm = "AM" || am_or_pm = "A.M.")
System.out.println("The time is " + time_hours + ":" + time_minutes + "am");
if(am_or_pm = "pm" || am_or_pm = "p.m." || am_or_pm = "PM" || am_or_pm = "P.M.")
System.out.println("The time is " + time_hours + ":" + time_minutes + "pm");
}To calculate time_hours should I just calculate this by adding the elapsed hour to the starting hour? I doubt it will be accurate for all situations.
Same for the time_minutes For example, if the starting minutes and the elapsed minutes were 50, it would be greater than 60. Also, not sure if it makes sense to separate hours and minutes like this, it's not required to in the question. I initally thought it would be easier to approach like this instead of allowing the user to input a double for the starting hour. ex. 5.7
I get the feeling that this is extremely simple, but nonetheless, I'm stuck, so any help would be appreciated.Well thanks to both of you. I did a little reading up on the modulus operator and coupled it with some logic (although, truthfully, I'm not really using to there actually being an application for the remainder of a division operation, since it's never really used very much in any of my Math courses) and the hours portion works perfectly now:
import java.util.Scanner;
public class ElapsedTimeCalculator
public static void main(String[] args)
int starting_hour;
//int starting_minutes; /*This is added in case the user wants to add minutes as well.*/
String am_or_pm;
int elapsed_hours;
//int elasped_minutes;
System.out.println("Welcome. This application will give you the time based on your input.");
System.out.println(" ");
Scanner input = new Scanner(System.in);
System.out.print("Enter the starting hour: ");
starting_hour = input.nextInt();
//System.out.print("Enter the starting minutes: ");
//starting_minutes = input.nextInt();
System.out.print("Enter either 'am' or pm': ");
am_or_pm = input.next();
System.out.print("Enter the number of elapsed hours: ");
elapsed_hours = input.nextInt();
input.close();
int time_hours = 0;
//int time_minutes;
String meridien;
if(am_or_pm.equals("am"))
time_hours = (starting_hour + elapsed_hours) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("am"))
time_hours = (starting_hour + elapsed_hours) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("AM"))
time_hours = (starting_hour + elapsed_hours) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("A.M."))
time_hours = (starting_hour + elapsed_hours) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("pm"))
time_hours = (starting_hour + elapsed_hours + 12) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("p.m."))
time_hours = (starting_hour + elapsed_hours + 12) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("PM"))
time_hours = (starting_hour + elapsed_hours + 12) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
else if(am_or_pm.equals("P.M."))
time_hours = (starting_hour + elapsed_hours + 12) % 24;
//time_minutes = (starting_minutes + elapsed_minutes) % 60;
if(time_hours < 12)
meridien = "A.M.";
System.out.println("The time is: " + time_hours + ":00 " + meridien);
else if(time_hours > 12)
meridien = "P.M.";
System.out.println("The time is: " + time_hours + ":00 " + meridien);
}Now the only thing is the minutes. My teacher did say she wants the user to have the option to input minutes also if he/she desires, so I do need it. However, the only problem is that if say the user inputs a "starting minute" of 14 for example, and 66 minutes elapsing, then (14 + 66) int/ 60 = 1r20 but using the modulus operator would only give me 20. So how will I be able to add any extra hours if it is necessary? -
To calculate elapsed time between two timestamp attributes
Hello,
I have two timestamp attributes (create_tmstmp & elapsed_tmstmp) in a table.
It has two rows and I need the difference in seconds between these two attributes.
The below query is returning negative value and incorrect value.
Any help is appreciated.
Row 1:
Create_tmstmp : 2/2/2010 9:53:15.832 PM
Elapsed_tmstmp : 2/3/2010 9:49:47.527 AM
Row 2:
Create_tmstmp : 2/3/2010 5:35:47.614 AM
Elapsed_tmstmp : 2/3/2010 11:03:15.937 AM
Select
( (extract(day from elapsed_tmstmp )-extract(day from create_tmstmp))*86400+
(extract(hour from elapsed_tmstmp )-extract(hour from create_tmstmp))*3600+
(extract(minute from elapsed_tmstmp)-extract(minute from create_tmstmp))*60+
(extract(second from elapsed_tmstmp)-extract(second from create_tmstmp))*1000) completed_tmstmp
From table_a;
The output is :
completedtmstmp_
74655
-11997
Thanks.
Edited by: solsam on Feb 4, 2010 11:57 AMhi,
The problem with cast to date is
SQL> select to_char(cast(to_timestamp('2/2/2010 9:53:15.832 PM','mm/dd/yyyy hh:mi:ss.ff pm') as dat
e),'mm/dd/yyyy hh:mi:ss pm') from dual
2 ;
TO_CHAR(CAST(TO_TIMEST
02/02/2010 09:53:16 pm
so cast rounds it up, resulting in:
SELECT (
CAST (TO_TIMESTAMP ('2/2/2010 9:53:15.832 PM', 'mm/dd/yyyy hh:mi:ss.ff pm') AS DATE)
- CAST (TO_TIMESTAMP ('2/2/2010 9:53:14.432 PM', 'mm/dd/yyyy hh:mi:ss.ff pm') AS DATE)
* 86400 x
FROM DUAL
X
2
A more exact answer would use, to_char and to_date to convert :
SELECT (
TO_DATE (TO_CHAR (TO_TIMESTAMP ('2/2/2010 9:53:15.832 PM', 'mm/dd/yyyy hh:mi:ss.ff pm'),
'mm/dd/yyyy hh:mi:ss pm'),
'mm/dd/yyyy hh:mi:ss pm')
- TO_DATE (TO_CHAR (TO_TIMESTAMP ('2/2/2010 9:53:14.432 PM', 'mm/dd/yyyy hh:mi:ss.ff pm'),
'mm/dd/yyyy hh:mi:ss pm'),
'mm/dd/yyyy hh:mi:ss pm')
* 86400 x
FROM DUAL
X
1
Edit:
Massimo Ruocchio's answer actually works better.
-AC
Edited by: user12026137 on Feb 9, 2010 12:45 PM -
How to use elapsed time function with state machine in Lab VIEW
Hello
I've been trying to use state machine with elapsed time function in order to sequentially start and stop my code. The arrangement is to start the code for 1 minute then stop for 5 minutes. I've attached the code, the problem is when I place the elapsed time function out of the while loop it doesn't work, on the other hand when I place it inside the loop it does work but it doesn't give the true signal to move to the next state.
Could you please have a look to my code and help me to solve this issue.
Regards
Rajab
Solved!
Go to Solution.
Attachments:
daq assistance thermocouple(sate machine raj).vi 436 KBRajab84 wrote:
Thanks apok for your help
even with pressing start it keeps running on wait case
could you please explain the code for me, the use of Boolean crossing, increment , and equal functions
Best Regards
Rajab
OK..I modded the example to stop after 2 cycles. Also recommend taking the free online LabVIEW tutorials.
run vi. case statement goes to "initialize", shift registers are initialized to their constants. goto "wait"
"start"= false, stay in current state. If true, transition to "1 min" case
reset elapsed timer with True from shift register(counter starts at zero)."time has elapsed"=false, stay in current state(1 min). If true, goto "5min" case
reset elapsed timer with True from shift register of previous case(counter starts at zero)."time has elapsed"=false, stay in current state(5 min). If true, goto "1min" case. Also, bool crossing is looking for "true-false" from "5 min" compare function to add cycle count.
Once cycle count reaches 2, stop while loop....
Attachments:
Untitled%202[1].vi 42 KB -
How can I get the elapse time for execution of a Query for a session
Hi ,
How can I get the elapse time for execution of a Query for a session?
Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
Thanks in advance.Hi
You can use the dbms_utility.get_time tool (gives binary_integer type value).
1/ Initialize you time and date of beginning :
v_beginTime := dbms_utility.get_time ;
2/ Run you procedure...
3/ Get end-time with :
v_endTime := dbms_utility.get_time ;
4/ Thus, calculate elapsed time by difference :
v_elapsTime := v_endTime - v_beginTime ;
This will give you time elapsed in of 100th of seconds...
Then you can format you result to give correct print time.
Hope it will help you.
AL -
Date Utility - calc age, elapsed time...
I need to calculate elapsed time between 2 dates, for example calc age based on DOB and Today. There must be a utility out there somewhere (free!). I'm sure I'm not the first one with this requirement.
try this
import java.util.*;
public class DateSub {
public static void main(String [] args) {
Calendar cal = Calendar.getInstance();
cal.set (1970,0,1);
long age = cal.getTime().getTime();
age = System.currentTimeMillis() - age;
System.out.println ("age = " + age + " milliseconds" );
age /= 1000;
System.out.println ("age = " + age + " seconds" );
age /= (3600*24);
System.out.println ("age = " + age + " days" );
long years = age/(365);
long days = age % 365;
System.out.println ("age = " + years + " years " + days + " days");
} -
Same sqlID with different execution plan and Elapsed Time (s), Executions time
Hello All,
The AWR reports for two days with same sqlID with different execution plan and Elapsed Time (s), Executions time please help me to find out what is reason for this change.
Please find the below detail 17th day my process are very slow as compare to 18th
17th Oct 18th Oct
221,808,602
21
2tc2d3u52rppt
213,170,100
72,495,618
9c8wqzz7kyf37
209,239,059
71,477,888
9c8wqzz7kyf37
139,331,777
1
7b0kzmf0pfpzn
144,813,295
1
0cqc3bxxd1yqy
102,045,818
1
8vp1ap3af0ma5
128,892,787
16,673,829
84cqfur5na6fg
89,485,065
1
5kk8nd3uzkw13
127,467,250
16,642,939
1uz87xssm312g
67,520,695
8,058,820
a9n705a9gfb71
104,490,582
12,443,376
a9n705a9gfb71
62,627,205
1
ctwjy8cs6vng2
101,677,382
15,147,771
3p8q3q0scmr2k
57,965,892
268,353
akp7vwtyfmuas
98,000,414
1
0ybdwg85v9v6m
57,519,802
53
1kn9bv63xvjtc
87,293,909
1
5kk8nd3uzkw13
52,690,398
0
9btkg0axsk114
77,786,274
74
1kn9bv63xvjtc
34,767,882
1,003
bdgma0tn8ajz9
Not only queries are different but also the number of blocks read by top 10 queries are much higher on 17th than 18th.
The other big difference is the average read time on two days
Tablespace IO Stats
17th Oct
Tablespace
Reads
Av Reads/s
Av Rd(ms)
Av Blks/Rd
Writes
Av Writes/s
Buffer Waits
Av Buf Wt(ms)
INDUS_TRN_DATA01
947,766
59
4.24
4.86
185,084
11
2,887
6.42
UNDOTBS2
517,609
32
4.27
1.00
112,070
7
108
11.85
INDUS_MST_DATA01
288,994
18
8.63
8.38
52,541
3
23,490
7.45
INDUS_TRN_INDX01
223,581
14
11.50
2.03
59,882
4
533
4.26
TEMP
198,936
12
2.77
17.88
11,179
1
732
2.13
INDUS_LOG_DATA01
45,838
3
4.81
14.36
348
0
1
0.00
INDUS_TMP_DATA01
44,020
3
4.41
16.55
244
0
1,587
4.79
SYSAUX
19,373
1
19.81
1.05
14,489
1
0
0.00
INDUS_LOG_INDX01
17,559
1
4.75
1.96
2,837
0
2
0.00
SYSTEM
7,881
0
12.15
1.04
1,361
0
109
7.71
INDUS_TMP_INDX01
1,873
0
11.48
13.62
231
0
0
0.00
INDUS_MST_INDX01
256
0
13.09
1.04
194
0
2
10.00
UNDOTBS1
70
0
1.86
1.00
60
0
0
0.00
STG_DATA01
63
0
1.27
1.00
60
0
0
0.00
USERS
63
0
0.32
1.00
60
0
0
0.00
INDUS_LOB_DATA01
62
0
0.32
1.00
60
0
0
0.00
TS_AUDIT
62
0
0.48
1.00
60
0
0
0.00
18th Oct
Tablespace
Reads
Av Reads/s
Av Rd(ms)
Av Blks/Rd
Writes
Av Writes/s
Buffer Waits
Av Buf Wt(ms)
INDUS_TRN_DATA01
980,283
91
1.40
4.74The AWR reports for two days with same sqlID with different execution plan and Elapsed Time (s), Executions time please help me to find out what is reason for this change.
Please find the below detail 17th day my process are very slow as compare to 18th
You wrote with different execution plan, I think, you saw plans. It is very difficult, you get old plan.
I think Execution plans is not changed in different days, if you not added index or ...
What say ADDM report about this script?
As you know, It is normally, different Elapsed Time for same statement in different day.
It is depend your database workload.
It think you must use SQL Access and SQl Tuning advisor for this script.
You can get solution for slow running problem.
Regards
Mahir M. Quluzade -
How can I make a timer that will record elapsed time up to 15 hours with a PCI-6503E DAQ card?
I'm a beginner LabVIEW programmer, but need to take measurements of elapsed time from the start of data acquisition for up to 15 hours. I'm using a PCI-6503E card. Looking at examples on the web and LabVIEW, itself, I was only able to find a way to take time measurements with a DAQ card up to 167 s, unless two counters were tied together, but there are no instructions on how to do that. Could someone help me? Thanks.
I suggest you to look in the Resouce Library: inside it there is plenty of useful examples.
I found this VI with two cascaded timers in the Measurement hardware > Counter/Timer > Event/Time Measurement cathegory:
http://zone.ni.com/devzone/devzoneweb.nsf/opendoc?openagent&5293158F4EC950C4862568C1005F6CD9&cat=C7029C9ACBD3DF7386256786000F8EE6
Hope this helps.
Roberto
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
What is wrong with this elapsed time counter?
I have been using this simple counter for a while. After unbundling the timestamp - there is always a '19' in the hours indicator. At first I was simply subtracting '19' and it worked fine. Then I ran a program for about 5 hours and the hour display changed to something odd (like a 16 or 17). Any ideas where the '19' comes from?
Thanks - Paul
Attachments:
simple elapsed timer.vi 9 KBOK, typically you don't want to jump through all these hoops and drag along comlex timing fiunctions just to keep elapsed time.
Some simpler suggestions would be (see image):
(A) To place a 1000ms wait inside the loop, then place a simple indicator at the [i] terminal. Set the indicator to relative time format with HH:MMS. Voila!
(B) If you need s, m, h in seperate indicators, just do a few simple calculations
(C) If you don't trust the loop delay, maybe because you do complicated calculations that might take longer than a second in the same loop, Get the elapsed time from the tick count difference.
Message Edited by altenbach on 02-08-2007 04:05 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
elapsedTime.png 14 KB -
Help with quit function and elapsed time function.
I have this annoying assignment game here and I am almost finished with it. I got two problems, the first is that the quit function partly works it quits from the game but it is giving me a "Guess is to high" message. I've tried so many things but nothing seems to work.
The other problem is that the elapsed time " *(long f = System.currentTimeMillis()/1000;)* " starts to count before you actually write something for example if you run the program without writing something for 5 minutes, the highscore list will show your time you finished the game + these 5 minutes.
If somebody could give me a hint or could explain to me how I could fix these problems I would be very thankful.
import java.util.*;
class Game {
public static void main(String[] arg) {
int RAN,Entered_number=0,count=0;
String guess1[] = new String[1];
int guess2[] = new int[1];
int time[] = new int[1];
String NP1[];
int NP2[];
int NP3[];
int j=0;
Scanner scan=new Scanner(System.in);
Scanner kb = new Scanner(System.in);
Random myRandomizer = new Random();
RAN= Math.abs(myRandomizer.nextInt() % 1000) + 1;
System.out.println("\t\t\t"+"Hello and welcome to this guessing game!");
System.out.println("\t\t\t"+"Start guessing, it's a number between 1 and 1000...");
System.out.print("--------------------------------------------------");
System.out.println("-----------------------------");
System.out.println("please enter your number:");
String control="";//control is just a name for the variable. it's used to read in the whole line if you have written something that is not a number.
String name="";
String answer="";
boolean okgame=true;//is used so that you can play the game as long as the variable okgame is true.
long f = System.currentTimeMillis()/1000;
while((Entered_number!=RAN) && okgame)//controls if the number is different then RAN and that okgame is true.
System.out.print(RAN);
System.out.print(">");
if(scan.hasNextInt())//checks in advance that what you have written is a number, if so then it can read it as Entered_number.
Entered_number=scan.nextInt();
else
control=scan.nextLine();//Reads int the whole line to control what has been written in.
if(control.equalsIgnoreCase("quit"))//if control is = quit, then compare to will return 0.
okgame=false; //if you have written quit okgame, you put in false to quit the game.
// Entered_number=0;//initiates entered_number all over again to show message stupid guess i wont count that.
if(okgame)//as long as okgame is true it will show the result otherwise you go to else to show that the game is finished.
if((Entered_number>RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
System.out.println("Guess is too high!");
count++;
else if((Entered_number<RAN)&&(Entered_number>=1)&&(Entered_number<=1000))
System.out.println("Guess is too low!");
count++;
else if((Entered_number>1000)||(Entered_number<1))
System.out.println("Stupid guess! I won't count that...");
else if (Entered_number==RAN)
long p = System.currentTimeMillis()/1000;
count++;
System.out.println("****Guess is CORRECT!");
System.out.print("****You guessed it in"+" "+count+" guesses and ");
System.out.print(p - f);
System.out.println(" seconds.");
System.out.println("please enter your name:");
System.out.print(">");
name=kb.next();
System.out.println("Do you want to play again ?(y/n)");
System.out.print(">");
answer=kb.next();
if(answer.equalsIgnoreCase("n"))
System.out.println("**** The game is over.");
okgame=false;
if(answer.equalsIgnoreCase("y"))
Random myRandom = new Random();
RAN = Math.abs(myRandom.nextInt() % 1000) + 1;
System.out.println("current high score list:");
long ttime = p-f;
int ta = (int)ttime;
j++;
if (j > 1){
NP1 = new String[j];
NP2 = new int[j];
NP3 = new int[j];
for (int n = 1; n < j; n++){
NP1[n-1] = guess1[n-1];
NP2[n-1] = guess2[n-1];
NP3[n-1] = time[n-1];
NP1[j-1] = name;
NP2[j-1] = count;
NP3[j-1] = ta;
guess1 = new String[j];
guess1 = NP1;
time = new int[j];
guess2 = new int[j];
guess2 = NP2;
time = NP3;
for (int w = 1; w < guess2.length; w++) {
for (int x = 1; x < guess2.length; x++) {
if (guess2[x] < guess2[x-1]) {
int z4, z5,z6,z7;
String z2, z3;
z4 = guess2[x];
z5 = guess2[x-1];
guess2[x] = z5;
guess2[x-1] = z4;
z2 = guess1[x];
z3 = guess1[x-1];
guess1[x] = z3;
guess1[x-1] = z2;
z6 = time[x];
z7 = time[x-1];
time[x] = z7;
time[x-1] = z6;
for (int al = 1; al < time.length; al++) {
for (int o = 1; o < time.length; o++) {
if (guess2[o] == guess2[o-1]) {
if (time[o] < time[o-1]) {
int z4, z5, z6 ,z7;
String z2, z3;
z2 = guess1[o]; z3 = guess1[o-1];
z4 = guess2[o]; z5 = guess2[o-1];
z6 = time[o]; z7 = time[o-1];
guess1[o] = z3; guess1[o-1] = z2;
guess2[o] = z5; guess2[o-1] = z4;
time[o] = z7; time[o-1] = z6;
else {
guess1[j-1] = name;
guess2[j-1] = count;
time[j-1] = ta;
System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
System.out.println("------\t\t----\t\t----------\t--------------");
for (int h = 0; h < j; h++) {
System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
System.out.println("");
System.out.println("Start guessing, it's a number between 1 and 1000...");
count=0;
//-----------------------------------------------------------------------------------------------------------------------------------------------------PS I'm not done with the comments yet so that could be a little confusing for you guys =P
Thanks!
/chillelse {
guess1[j-1] = name;
guess2[j-1] = count;
time[j-1] = ta;
System.out.println("Number\t\tName\t\tHigh Score\tTime (Seconds)");
System.out.println("------\t\t----\t\t----------\t--------------");
for (int h = 0; h < j; h++) {
System.out.println(" " + (h+1) + "\t\t" + guess1[h] + "\t\t" + guess2[h] + "\t\t" + time[h]);
System.out.println("");
System.out.println("Start guessing, it's a number between 1 and 1000...");
f=System.currentTimeMillis()/1000;////////////include this line here
count=0;
} -
Query Execution/Elapsed Time and Oracle Data Blocks
Hi,
I have created 3 tables with one column only. As an example Table 1 below:
SQL> create table T1 ( x char(2000));
So 3 tables are created in this way i.e. T1,T2 and T3.
T1 = in the default database tablespace of 8k (11g v11.1.0.6.0 - Production) (O.S=Windows).
T2 = I created in a Tablespace with Blocksize 16k.
T3 = I created in a Tablespace with Blocksize 4k. In the same Instance.
Each table has approx. 500 rows (So, table sizes are same in all the cases to test Query execution time ). As these 3 tables are created under different data block sizes so the ALLOCATED no. of data blocks are different in all cases.
T1 = 8k = 256 Blocks = 00:00:04.76 (query execution time/elapsed time)
T2 = 16k=121 Blocks = 00:00:04.64
T3 = 4k = 490 Blocks = 00:00:04.91
Table Access is FULL i.e. I have used select * from table_name; in all 3 cases. No Index nothing.
My Question is why query execution time is nearly the same in all 3 cases because Oracle has to read all the data blocks in each case to fetch the records and there is a much difference in the allocated no. of blocks ???
In 4k block size example, Oracle has to read just 121 blocks and it's taking nearly the same time as it's taking to read 490 blocks???
This is just 1 example of different data blocks. I have around 40 tables in each block size tablespace and the result are nearly the same. It's very strange for me because there is a much difference in the no. of allocated blocks but execution time is almost the same, only difference in milliseconds.
I'll highly appreciate the expert opinions.
Bundle of thanks in advance.
Best Regards,Hi Chris,
No I'm not using separate databases, it's 8k database with non-standard blocksizes of 16k and 4k.
Actually I wanted to test the Elapsed time of these 3 tables, so for that I tried to create the same size
tables.
And how I equalize these is like I have created one column table with char(2000).
555 MB is the figure I wanted to use for these 3 tables ( no special figure, just to make it bigger than the
RAM used for my db at the db startup to be sure of not retrieving the records from cache).
so row size with overhead is 2006 * 290,000 rows = 581740000(bytes) / 1024 = 568105KB / 1024 = 555MB.
Through this math calculation I thought It will be the total table size. So I Created the same no. of rows in 3 blocksizes.
If it's wrong then what a mes because I was calculating tables sizes in the same way from the last few months.
Can you please explain a little how you found out the tables sizes in different block sizes.Though I understood how you
calculated size in MB from these 3 block sizes
T8K =97177 BLOCKS=759MB *( 97177*8 = 777416KB / 1024 = 759MB )*
T16K=41639 BLOCKS=650MB
BT4K=293656 BLOCKS=1147MB
For me it's new to calculate the size of a table. Can you please tell me then how many rows I can create in each of
these 3 tables to make them equal in MB to test for elapsed time.
Then I'll again run my test and put the results here. Because If I've wrongly calculated table sizes then there is no need to talk about elapsed time. First I must equalize the table sizes properly.
SQL> select sum(bytes)/1024/1024 "Size in MB" from dba_segments> 2 where segment_name = 'T16K';
Size in MB
655
Is above SQL is correct to calculate the size or is it the correct alternative way to your method of calculating the size??
I created the same table again with everything same and the result is :
SQL> select num_rows,blocks from user_tables where table_name = 'T16K';NUM_ROWS BLOCKS
290000 41703
64 more blocks are allocated this time so may be that's y it's showing total size of 655 instead of 650.
Thanks alot for your help.
Best Regards,
KAm
Edited by: kam555 on Nov 20, 2009 5:57 PM -
Hello,
I'm trying to measure the time between 2 datapoints.
When the data acquirement begins the time should be saved and when the signal reaches 90% of it's max.
Those 2 times then get subtracted and then you have the elapsed time.
But I'm not quite sure how to do this... I was thinking with flat sequences.
Solved!
Go to Solution.Are you constantly capturing a signal? What is your sample rate?
What you need to do first to capture the signal. You can then find the maximum value with the Array Max & Min function. Calculate your 90% (0.9*Max). Search the data until your get greater or equal to the 90% mark. Get that sampling number. Your time is then number of samples to the 90% mark divided by the sample rate (in Samples/Second).
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
How to get elapsed time in case struture?
I'm trying to get Elapsed Time VI to work but couldn't figure out how to use it properly.
I have a subVI with state machine structure to decode data stream from serial port.
State1 uses VISA read to read a byte and check if it is the Start of Frame. If TRUE, goes to State2. If FALSE, loop back to State1 and try again.
If the State1 keeps getting FALSE for certain time (e.g. 5 seconds), stop the subVI and insert custom error code.
So I have to calculate the elapsed time since State1 starts to be FALSE and keeps to be FALSE.
I tried to use Elapsed Time VI but have problem of understanding it well.
Is there any other better solution than using Elapsed Time VI? Also, how long is the execution time of Elapsed Time VI?
Any suggestion will be very much appreciated.Hi,
The Boolean output (Time Elapsed) in Elapse Time VI should give True when time got elapsed.
Else we can simulate using "Tick Count (ms)", which counts the ticks in milisecond. You can move on to state 2 when count reaches to reauired duration.
We can give you better idea if you post the code VI.
Regards
Haneef
Maybe you are looking for
-
How to use ipod touch when I already own an iphone on one computer?
I have a dilemma. when I try to setup my brand new ipod touch I got for xmas, it says i must setup it up as new device or restore from backup. the problem is I use this computer to sync to my iphone 3gs. itunes wont let me sync to an ipod touch and a
-
Hi All, I am not getting LOGON USER ID ( who has logged into the AM 7.1 ) after redirecting to the Application, This is Happened in Windows 2000 IIS 5.0 for an ASP application, I m getting the same when I m trying it in WINDOWs2003 IIS 6.0, I dont kn
-
All, Is it possible to reference a namespace to a file on your hard disk? All the examples I have seen use http addresses. I have tried the file URI but receive the message given below. Thanks, Brian MSV Message: start parsing a grammar. namespace "f
-
Java_es-5-websuite-ga-windows-x86 installation issue not setting JAVA_HOME
looks like the installer from java_es-5-websuite-ga-windows-x86.zip is not setting the JAVA_HOME variable correctly. C:\Sun\JavaES5\DSEE\dscc6\bin>dsccsetup.exe initialize Failed to create child process ["1/bin/java.exe" -Dsun.directory.clip. [...]
-
How do I delete a Gmail folder which doesn't show in the Subscribe list?
I have a folder in my Gmail Inbox which I can't delete using either Delete, and which isn't showing up in the Subscribe list. How do I delete it? It doesn't exist in my online Gmail account. I get an error message that the Gmail server can't delete a