Skip to content

Commit 94b1b3b

Browse files
stepanchegfacebook-github-bot
authored andcommitted
ProfileDataImpl
Summary: Preparation to store raw (instead of serialized) profile data in `ProfileData`. Raw mode need to be stored to be able to merge profile data (D38681490). Reviewed By: bobyangyf Differential Revision: D38681027 fbshipit-source-id: 1579ad8a1198b9812c071a4e10192cb5ad7ca15a
1 parent dbcaa78 commit 94b1b3b

File tree

1 file changed

+10
-3
lines changed
  • starlark/src/eval/runtime/profile

1 file changed

+10
-3
lines changed

starlark/src/eval/runtime/profile/data.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,32 @@ use anyhow::Context;
2222

2323
use crate::eval::ProfileMode;
2424

25+
#[derive(Clone, Debug)]
26+
pub(crate) enum ProfileDataImpl {
27+
Other(String),
28+
}
29+
2530
/// Collected profiling data.
2631
#[derive(Clone, Debug)]
2732
pub struct ProfileData {
2833
profile_mode: ProfileMode,
2934
/// Serialized to text (e.g. CSV or flamegraph).
30-
profile: String,
35+
profile: ProfileDataImpl,
3136
}
3237

3338
impl ProfileData {
3439
pub(crate) fn new(profile_mode: ProfileMode, profile: String) -> ProfileData {
3540
ProfileData {
3641
profile_mode,
37-
profile,
42+
profile: ProfileDataImpl::Other(profile),
3843
}
3944
}
4045

4146
/// Generate a string with profile data (e.g. CSV or flamegraph, depending on profile type).
4247
pub fn gen(&self) -> anyhow::Result<String> {
43-
Ok(self.profile.clone())
48+
match &self.profile {
49+
ProfileDataImpl::Other(profile) => Ok(profile.clone()),
50+
}
4451
}
4552

4653
/// Write to a file.

0 commit comments

Comments
 (0)