Can we calculate time taken to execute each step in protractor? - angularjs

I have a task in which I have to calculate the time taken by each step, for example if we are clicking on a link, how much time is taken to load the page and next step to be executed.
I want fail the test case if time taken is more then say 2 seconds.
I have tried using protractor-perf and it gives me the readings below and these don't help, or I am not able to read anything correctly.
{ Styles: 0,
Javascript: 0,
numAnimationFrames: 4625,
numFramesSentToScreen: 4625,
droppedFrameCount: 417,
meanFrameTime_raf: 18.242160830084256,
framesPerSec_raf: 54.81806729556069,
connectEnd: 1524251882749,
connectStart: 1524251882459,
domComplete: 1524251916054,
domContentLoadedEventEnd: 1524251916053,
domContentLoadedEventStart: 1524251916050,
domInteractive: 1524251916050,
domLoading: 1524251883038,
domainLookupEnd: 1524251882459,
domainLookupStart: 1524251882459,
fetchStart: 1524251882458,
firstPaint: 33600.99983215332,
loadEventEnd: 1524251916055,
loadEventStart: 1524251916054,
navigationStart: 1524251882456,
redirectEnd: 0,
redirectStart: 0,
requestStart: 1524251882749,
responseEnd: 1524251883592,
responseStart: 1524251883032,
secureConnectionStart: 0,
unloadEventEnd: 0,
unloadEventStart: 0,
loadTime: 33597,
domReadyTime: 4,
readyStart: 2,
redirectTime: 0,
appcacheTime: 1,
unloadEventTime: 0,
domainLookupTime: 0,
connectTime: 290,
requestTime: 843,
initDomTreeTime: 32458,
loadEventTime: 1 }
I have also tried using log-timestamp and I can print the timestamp to log but cannot get the difference to use it in a variable and fail the test case.
I get the output like this in the log:
[2018-04-20T19:19:13.325Z] Start
[2018-04-20T19:19:14.046Z] Step1
[2018-04-20T19:19:47.667Z] Step2
[2018-04-20T19:19:50.304Z] Step3
[2018-04-20T19:19:52.111Z] Step4
[2018-04-20T19:19:57.344Z] Step5
[2018-04-20T19:19:59.029Z] Step6
I would really appreciate your help guys, this has wasted a lot my time.

Related

RRule not setting correct time if dtstart is set

I try to make an rrule instance and then set the start date/time (dtstart) but the events get the wrong time.
I initialize a rrule instance with a basis rrule string:
RRULE:FREQ=WEEKLY;INTERVAL=1;WKST=MO;COUNT=20
I set the dtstart date in the rrule.options like so:
rrule.options.dtstart = new Date(Date.UTC(2019, 1, 4, 12, 30, 0))
I console.log rrule.all() to see the generated events. All events now have the current time instead of the time set via dtstart. It should show 12:30 instead
I made this sandbox demonstrating the problem.
Now, when I do exactly the same in rrule.js demo page, I get correct results.
On this demo page, do the following to see what I mean:
These are the results:
As you can see, time of the events is set correctly!
Any advice appreciated!
Found the answer:
If you set distart explicitly in the constructor, then the problem is solved.
Compare these examples:
Example one: gives correct results:
const rrule = new RRule({
freq: RRule.WEEKLY,
interval: 1,
wkst: RRule.MO,
count: 20,
dtstart: new Date(Date.UTC(2019, 1, 4, 12, 30, 0))})
Example two: gives wrong results
const rrule = new RRule({
freq: RRule.WEEKLY,
interval: 1,
wkst: RRule.MO,
count: 20})
rrule.options.dtstart = new Date(Date.UTC(2019, 1, 4, 14, 30, 0));
To me, this looks a bit counter intuitive because setting dtstart should always give the same result whether you set it in the constructor or set it afterwards.

How to plot a Real time graph in Zeppelin?

I am trying to use zeppelin to plot a realtime graph. I have doing a sentiment analysis on tweets on per minute . I am able to query statically and plot a graph. But i would like this to be done dynamically. I am new to zeppelin and do not have much knowledge about angularJS. What should be the correct approach to this problem?
val final_score=uni_join.map{case((year,month,day,hour,minutes),(tweet_count,sentiment))=>(year, month, day, hour, minutes(sentiment/tweet_count).ceil)}
final_score.saveToCassandra("twitter", "score",writeConf = WriteConf(ttl = TTLOption.constant(1000)))
final_score.foreachRDD(score => {
val rowRDD =score.map{case(year,month,day,hour,minutes,sentiment) =>(year,month,day,hour,minutes,sentiment) }
val tempDF = sqlContext.createDataFrame(rowRDD)
z.angularBindGlobal("stream", parsed) //to bind parsed to stream.
tempDF.registerTempTable("realTimeTable")
})
Doing a query on the above table , i am able to get the graph. But i would like to dynamically update the graph every minute in order to keep in sync with the sentiment score .
Thanks prior.
[update] the angular part for the zeppelin notebook are as follows:
%angular
<div id="graph" style="height: 100%; width: 100%">
<canvas id="myChart" width="400" height="400"></canvas>
<div id="legendDiv"></div>
</div>
<script>
function initMap() {
var colorList = ["#fde577", "#ff6c40", "#c72a40", "#520833", "#a88399"]
var el = angular.element($('#stream'));
console.log("El is "+el) //returns el as object
angular.element(el).ready(function() {
console.log('Hello')
window.locationWatcher =el.$scope.$watch('stream', function(new, old){
console.log('changed');}, true)})
</script>
But running this code keeps returning the following error.
vendor.js:29 jQuery.Deferred exception: Cannot read property '$watch' of undefined TypeError: Cannot read property '$watch' of undefined
The spark version that i am using is 1.6
And Zeppelin is 0.6
spark-highcharts since version 0.6.3 support Spark Structured Streaming.
For a structuredDataFrame after aggregation, with the following code in one Zeppelin paragraph. The OutputMode can be either append or complete depends how the structureDataFrame is aggregated.
import com.knockdata.spark.highcharts._
import com.knockdata.spark.highcharts.model._
val query = highcharts(
structuredDataFrame.seriesCol("country")
.series("x" -> "year", "y" -> "stockpile")
.orderBy(col("year")), z, "append")
And the following code in the next paragraph. The chart in this paragraph will be updated when there are new data coming to the structureDataFrame.
StreamingChart(z)
Run following code to stop update the chart.
query.stop()
Here is the example generate structureDataFrame.
spark.conf.set("spark.sql.streaming.checkpointLocation","/usr/zeppelin/checkpoint")
case class NuclearStockpile(country: String, stockpile: Int, year: Int)
val USA = Seq(0, 0, 0, 0, 0, 6, 11, 32, 110, 235, 369, 640,
1005, 1436, 2063, 3057, 4618, 6444, 9822, 15468, 20434, 24126,
27387, 29459, 31056, 31982, 32040, 31233, 29224, 27342, 26662,
26956, 27912, 28999, 28965, 27826, 25579, 25722, 24826, 24605,
24304, 23464, 23708, 24099, 24357, 24237, 24401, 24344, 23586,
22380, 21004, 17287, 14747, 13076, 12555, 12144, 11009, 10950,
10871, 10824, 10577, 10527, 10475, 10421, 10358, 10295, 10104).
zip(1940 to 2006).map(p => NuclearStockpile("USA", p._1, p._2))
val USSR = Seq(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5, 25, 50, 120, 150, 200, 426, 660, 869, 1060, 1605, 2471, 3322,
4238, 5221, 6129, 7089, 8339, 9399, 10538, 11643, 13092, 14478,
15915, 17385, 19055, 21205, 23044, 25393, 27935, 30062, 32049,
33952, 35804, 37431, 39197, 45000, 43000, 41000, 39000, 37000,
35000, 33000, 31000, 29000, 27000, 25000, 24000, 23000, 22000,
21000, 20000, 19000, 18000, 18000, 17000, 16000).
zip(1940 to 2006).map(p => NuclearStockpile("USSR/Russia", p._1, p._2))
input.addData(USA.take(30) ++ USSR.take(30))
val structureDataFrame = input.toDF
And the following code can be simulate to update the chart. The chart will be updated when the following code run.
input.addData(USA.drop(30) ++ USSR.drop(30))
NOTE: The example using Zeppelin 0.6.2 and Spark 2.0
NOTE: Please check the highcharts license for commercial usage

Why can't I retrieve the master appointment of a series via `AppointmentCalendar.FindAppointmentsAsync`?

I'm retrieving multiple appointments via AppointmentCalendar.FindAppointmentsAsync. I'm evaluating the Recurrence.RecurrenceType and noticed an unexpected value of 1 for master appointments of a series. I expect the Recurrence.RecurrenceType to be 0 (Master) but instead it is 1 (Instance).
(Note: I added AppointmentProperties.Recurrence to FindAppointmentsOptions.FetchProperties that is passed to GetAppointmentsAsync, so the Recurrence data should be fetched propertly.)
To double check I retrieved the respective master appointment via GetAppointmentAsync (instead of FindAppointmentsAsync) using its LocalId - and here the RecurrenceType is correctly set to 0.
Here is demo output for a test appointment series:
Data gotten by FindAppointmentsAsync (Instance??):
"Recurrence": {
"Unit": 0,
"Occurrences": 16,
"Month": 1,
"Interval": 1,
"DaysOfWeek": 0,
"Day": 1,
"WeekOfMonth": 0,
"Until": "2016-09-29T02:00:00+02:00",
"TimeZone": "Europe/Budapest",
"RecurrenceType": 1,
"CalendarIdentifier": "GregorianCalendar"
},
"StartTime": "2016-09-14T19:00:00+02:00",
"OriginalStartTime": "2016-09-14T19:00:00+02:00",
Data gotten by GetAppointmentAsync for the same appointment (Master):
"Recurrence": {
"Unit": 0,
"Occurrences": 16,
"Month": 1,
"Interval": 1,
"DaysOfWeek": 0,
"Day": 1,
"WeekOfMonth": 0,
"Until": "2016-09-29T02:00:00+02:00",
"TimeZone": "Europe/Budapest",
"RecurrenceType": 0,
"CalendarIdentifier": "GregorianCalendar"
},
"StartTime": "2016-09-14T19:00:00+02:00",
"OriginalStartTime": null,
Notice the difference in RecurrenceType. Also note that OriginalStartTime is set to null for the master gotten by GetAppointmentAsync but has a value for the appointment gotten by FindAppointmentsAsync.
You can also see that the StartTime for the master appointment is the start time set for the alleged Instance (which in reality is the master).
Shouldn't FindAppointmentsAsync return a master as the first element of a series, instead of an instance?
(SDK: 10.0.14393.0, Anniversary)
Code to explicitly find such a master/instance situation for a given calendar:
var appointmentsCurrent = await calendar.FindAppointmentsAsync(DateTimeOffset.Now, TimeSpan.FromDays(365), findAppointmentOptions);
foreach(var a in appointmentsCurrent)
{
var a2 = await calendar.GetAppointmentAsync(a.LocalId);
if (a2.Recurrence?.RecurrenceType == RecurrenceType.Master &&
a2.StartTime == a.StartTime &&
a.Recurrence?.RecurrenceType == RecurrenceType.Instance &&
a.OriginalStartTime == a2.StartTime)
{
Debug.WriteLine("Gotcha!");
}
}
I tested above code on my side. If you get the count of the appointments which are got from FindAppontmentsAsync by the following code:var count=appointmentsCurrent.Count;, you will find it does return the count of the appointment instances, not the count of master appointments. So the FindAppontmentsAsync method got all instances of the appointments not master appointments. This is the reason why the RecurrenceType is instance.
It seems like we can get one master appointment by method GetAppointmentAsync as you mentioned above, so I suppose this may not block you.
If you think this is not a good design for this API or you require a API for finding all the master appointments in one calendar, you can submit your ideas to the windows 10 feedback tool or the user voice site.

Kernel do_gettimeofday going to past

Using Kernel 3.9, the do_gettimeofday seems to be going into the past, for instance:
do_gettimeofday(&t);
time_to_tm(t.tv_sec, 0, &broken);
printk("One: %d:%d:%d:%ld\n", broken.tm_hour, broken.tm_min, broken.tm_sec, t.tv_usec);
(...) some processing
do_gettimeofday(&t);
time_to_tm(t.tv_sec, 0, &broken);
printk("Two: %d:%d:%d:%ld\n", broken.tm_hour, broken.tm_min, broken.tm_sec, t.tv_usec);
It shows:
[ 140.754752] One: 0:2:15:761239
[ 140.755139] Two: 0:2:8:539096
How is this possible ?

Unable to play two sounds at the same time

Can somebody explain me why I cant play two sounds at the same time ?
here a part of the code :
#include <fmod.h>
FMOD_SYSTEM *system;
FMOD_SOUND *dooropen;
FMOD_SOUND *keydoor;
FMOD_SOUND *slap;
FMOD_SOUND *bomb;
FMOD_SOUND *scratch;
FMOD_SOUND *secret;
FMOD_SOUND *pickey;
FMOD_SOUND *caisse;
FMOD_RESULT resultat1;
FMOD_RESULT resultat2;
FMOD_RESULT resultat3;
FMOD_RESULT resultat4;
FMOD_RESULT resultat5;
FMOD_RESULT resultat6;
FMOD_RESULT resultat7;
FMOD_RESULT resultat8;
FMOD_System_Create(&system);
FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
resultat1 = FMOD_System_CreateSound(system, "sound/door-open.mp3", FMOD_CREATESAMPLE, 0, &dooropen);
resultat2 = FMOD_System_CreateSound(system, "sound/key-door.wav", FMOD_CREATESAMPLE, 0, &keydoor);
resultat3 = FMOD_System_CreateSound(system, "sound/slap.wav", FMOD_CREATESAMPLE, 0, &slap);
resultat4 = FMOD_System_CreateSound(system, "sound/bomb.wav", FMOD_CREATESAMPLE, 0, &bomb);
resultat5 = FMOD_System_CreateSound(system, "sound/scratch.wav", FMOD_CREATESAMPLE, 0, &scratch);
resultat6 = FMOD_System_CreateSound(system, "sound/secret.wav", FMOD_CREATESAMPLE, 0, &secret);
resultat7 = FMOD_System_CreateSound(system, "sound/pickey.wav", FMOD_CREATESAMPLE, 0, &pickey);
resultat8 = FMOD_System_CreateSound(system, "sound/caisse.wav", FMOD_CREATESAMPLE, 0, &caisse);
And I call my sounds like this :
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, scratch, 0, NULL);
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, bomb, 0, NULL);
I think there's a channel problem because when I played "bomb" I can hear it (this sound is like 3 seconds) but if the "scratch" sounds happens the sound "bomb" is stopping...
The second parameter in FMOD_System_Init() is maxchannels. Just set it to 2 or higher. In the official tutorial they use 100.
As said before init the system with more channels
and
update the FMOD_SYSTEM after each FMOD_System_PlaySound.
Just insert
FMOD_System_Update(system);
Then it will be okay.
try creating new systems for the amount of sounds you want to play simultaneously, or you can try using FSOUND_Play instead of FSOUND_Init.
or you can also check out the Hekkus Sound System. I used it already for multiple sounds and worked, but it doesn't support mp3.
Create one channel per one sound and it will works fine or use FMOD_CHANNEL_FREE

Resources