Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mark_debug_sessions_with_ID <- function(sampleObs, index){
- print(paste("Processing partition of size", nrow(sampleObs)))
- index_initial = index
- #List of messages representing interactions of developers with Visual Studio IDE for debugging
- msgs_IDE_interactions = ('^View.Locals|Dbug.QuickWatch|Debug.AddWatch|Debug.StepOver|Debug.StepInto|Debug.StepOut|De-
- bug.SetNextStatement|Debug.RunToCursor|View.ImmediateWindow|Debug.Immediate|View.CallStack|Debug.CallStack|View.Autos|View.Output|Debug.Output
- |Debug.StopDebugging|Debug.Start|Debug.StartDebugTarget|TestExplorer.DebugSelectedTests|Debug.Restart|Debug.AttachtoProcess|
- TestExplorer.DebugAllTestsInContext|TestExplorer.DebugAllTests|View.SolutionExplorer|Debug.ToggleBreakpoint|Debug.EnableBreakpoint|
- View.FindandReplace|View.FindResults1|View.SandoSearch|Edit.FindinFiles|Edit.GoToDefinition|View.FindSymbolResults|
- Edit.FindAllReferences|ReSharper.ReSharper.GotoDeclaration|Edit.NavigateTo|ReSharper.ReSharper.FindUsages|Edit.GoToDeclaration|View.CallHierarchy$')
- indexes_matches <-grep(pattern=msgs_IDE_interactions, sampleObs$sample, invert=F)
- last_timestamp = strptime(sampleObs$timestamp[1], format="%Y-%m-%d %H:%M:%S")
- last_developer = sampleObs$developer[1]
- #if a sequence ID is 0, then the sequence is not part of a debugging session
- sequenceIds = c(0*1:nrow(sampleObs))
- print(paste("Marking all the messages in data frame of size", nrow(sampleObs)," with a debug sequence ID in thread", index))
- time_before_loop = proc.time()
- for(i in 1: (nrow(sampleObs)))
- {
- cur_timestamp = strptime(sampleObs$timestamp[i], format="%Y-%m-%d %H:%M:%S")
- cur_developer = sampleObs$developer[i]
- #We have a match. Now check if the timestamp of the current sequence is within 30 seconds of the last one
- if(i %in% indexes_matches)
- {
- sequenceIds[i] = index
- #it is within 30 seconds, then continue session and keep the same index
- if(cur_timestamp <= last_timestamp + 30)
- {
- sequenceIds[i] = index
- }
- #it is not within 30 seconds, then start a new debugging session increasing the index
- else
- {
- index = index + 1
- sequenceIds[i] = index
- }
- last_timestamp = cur_timestamp
- last_developer = cur_developer
- }
- else
- {
- #no match. again, check if the timestamp is within 30 seconds from the last action in the debugging session
- #is within it, then assign the sequence ID to the current action
- if( (cur_timestamp <= last_timestamp + 30) && (cur_developer == last_developer))
- {
- sequenceIds[i] = index
- }
- else
- {
- #not within 30 seconds, then just assign 0. stray action not within a debugging session
- sequenceIds[i] = 0
- }
- }
- if(i %% FREQUENCY_PRINT == 0)
- {
- print(paste(i, " messages have been processed."))
- }
- }
- time_after_loop = proc.time()
- elapsed_time = time_after_loop[3] - time_before_loop[3]
- print(paste("Algorithm has run in ", elapsed_time, "s for data frame of size", nrow(sampleObs)))
- sampleObs$SequenceID<-sequenceIds
- #now remove from the data frame all the sequences that are marked with a sequence ID = 0
- sampleObsOutput = sampleObs[which(sampleObs$SequenceID != 0), ]
- last_sequence_id = sampleObsOutput$SequenceID[nrow(sampleObsOutput)]
- amount_sequences = last_sequence_id - index_initial + 1
- # print(paste("Amount of sequences identified: ", (amount_sequences), sep=""))
- return(sampleObsOutput)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement