Skip to content

Instantly share code, notes, and snippets.

@vishalratna-microsoft
Created December 11, 2021 15:45
Show Gist options
  • Save vishalratna-microsoft/ac2da5e5cbf77de7bd871937f8b0952e to your computer and use it in GitHub Desktop.
Save vishalratna-microsoft/ac2da5e5cbf77de7bd871937f8b0952e to your computer and use it in GitHub Desktop.
Snippet capture API
override fun onCreate(savedInstanceState: Bundle?) {
Snippet.capture { // starts the measurement
var prefs = NewsApplication.get(this).getPrefs()
val component = NewsApplication.get(this).applicationComponent.plus(NewsFeedModule())
component.inject(this)
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_news_feed)
viewModel = ViewModelProvider(this, viewModelFactory).get(NewsFeedActivityViewModelImpl::class.java)
registerLiveDataObservers()
} // ends the measuremement here.
}
// Automatically captures the execution context and prints the pretty logs.
// 2021-12-11 21:13:15.833 22634-22634/com.takehome.demoapp D/DemoApp: [Class = NewsFeedActivity]|::::|[Method = onCreate]|::::|<Line no. 46>|::::|[Thread name = main]|::::||::::|(121 ms)
// 2021-12-11 21:13:15.861 22634-22634/com.takehome.demoapp D/DemoApp: [Class = NewsFeedActivity]|::::|[Method = onStart]|::::|<Line no. 115>|::::|[Thread name = main]|::::||::::|(16 ms)
// |::::||::::|(223 ms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment