mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1690624 - Add profiler rust API for thread registration/unregistration r=gerald,emilio
Differential Revision: https://phabricator.services.mozilla.com/D116515
This commit is contained in:
parent
f409532d55
commit
5bcc4d95af
@ -140,12 +140,6 @@ void* get_proc_address_from_glcontext(void* glcontext_ptr,
|
||||
return reinterpret_cast<void*>(ret);
|
||||
}
|
||||
|
||||
void gecko_profiler_register_thread(const char* name) {
|
||||
PROFILER_REGISTER_THREAD(name);
|
||||
}
|
||||
|
||||
void gecko_profiler_unregister_thread() { PROFILER_UNREGISTER_THREAD(); }
|
||||
|
||||
void record_telemetry_time(mozilla::wr::TelemetryProbe aProbe,
|
||||
uint64_t aTimeNs) {
|
||||
uint32_t time_ms = (uint32_t)(aTimeNs / 1000000);
|
||||
|
@ -29,8 +29,6 @@ void gfx_critical_error(const char* msg);
|
||||
void gecko_printf_stderr_output(const char* msg);
|
||||
void* get_proc_address_from_glcontext(void* glcontext_ptr,
|
||||
const char* procname);
|
||||
void gecko_profiler_register_thread(const char* threadname);
|
||||
void gecko_profiler_unregister_thread();
|
||||
|
||||
void gecko_profiler_start_marker(const char* name);
|
||||
void gecko_profiler_end_marker(const char* name);
|
||||
|
@ -9,3 +9,9 @@
|
||||
#include "ProfilerBindings.h"
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
void gecko_profiler_register_thread(const char* aName) {
|
||||
PROFILER_REGISTER_THREAD(aName);
|
||||
}
|
||||
|
||||
void gecko_profiler_unregister_thread() { PROFILER_UNREGISTER_THREAD(); }
|
||||
|
@ -14,7 +14,8 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
// TODO: Add the profiler API bindings here.
|
||||
void gecko_profiler_register_thread(const char* aName);
|
||||
void gecko_profiler_unregister_thread();
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
@ -3,5 +3,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
///! Profiler Rust API
|
||||
mod thread;
|
||||
|
||||
mod thread {}
|
||||
pub use thread::*;
|
||||
|
27
tools/profiler/rust-api/src/thread.rs
Normal file
27
tools/profiler/rust-api/src/thread.rs
Normal file
@ -0,0 +1,27 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
///! Profiler API for thread registration and unregistration.
|
||||
use std::ffi::CString;
|
||||
|
||||
extern "C" {
|
||||
fn gecko_profiler_register_thread(name: *const ::std::os::raw::c_char);
|
||||
fn gecko_profiler_unregister_thread();
|
||||
}
|
||||
|
||||
/// Register a thread with the Gecko Profiler.
|
||||
pub fn register_thread(thread_name: &str) {
|
||||
let name = CString::new(thread_name).unwrap();
|
||||
unsafe {
|
||||
// gecko_profiler_register_thread copies the passed name here.
|
||||
gecko_profiler_register_thread(name.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
/// Unregister a thread with the Gecko Profiler.
|
||||
pub fn unregister_thread() {
|
||||
unsafe {
|
||||
gecko_profiler_unregister_thread();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user