Skip to content

Instantly share code, notes, and snippets.

View vishalratna-microsoft's full-sized avatar

Vishal Ratna vishalratna-microsoft

  • Microsoft
  • Bangalore
View GitHub Profile
@vishalratna-microsoft
vishalratna-microsoft / NewActivity.kt
Created December 11, 2021 16:00
End the tag based measurement in Activity class
override fun onCreate(savedInstanceState: Bundle?) {
var prefs = NewsApplication.get(this).getPrefs()
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()
@vishalratna-microsoft
vishalratna-microsoft / NewsApplication.java
Last active December 11, 2021 15:55
Start and end the measurement using tags.
class NewsApplication : Application() {
override fun onCreate() {
super.onCreate()
if(BuildConfig.DEBUG) {
Snippet.install(Snippet.MeasuredExecutionPath())
Snippet.newFilter("Carausell")
Snippet.addFlag(Snippet.FLAG_METADATA_LINE or Snippet.FLAG_METADATA_THREAD_INFO)
}
@vishalratna-microsoft
vishalratna-microsoft / SomeActivity.kt
Created December 11, 2021 15:45
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.
public class SampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if(BuildConfig.DEBUG) {
Snippet.install(new Snippet.MeasuredExecutionPath());
Snippet.newFilter("SampleFilter");
Snippet.addFlag(Snippet.FLAG_METADATA_LINE | Snippet.FLAG_METADATA_THREAD_INFO);
}