|
@@ -11,14 +11,15 @@ class ProfileModel;
|
|
|
|
|
|
class ProfileNode : public RefCounted<ProfileNode> {
|
|
class ProfileNode : public RefCounted<ProfileNode> {
|
|
public:
|
|
public:
|
|
- static NonnullRefPtr<ProfileNode> create(const String& symbol, u32 address, u32 offset)
|
|
|
|
|
|
+ static NonnullRefPtr<ProfileNode> create(const String& symbol, u32 address, u32 offset, u64 timestamp)
|
|
{
|
|
{
|
|
- return adopt(*new ProfileNode(symbol, address, offset));
|
|
|
|
|
|
+ return adopt(*new ProfileNode(symbol, address, offset, timestamp));
|
|
}
|
|
}
|
|
|
|
|
|
const String& symbol() const { return m_symbol; }
|
|
const String& symbol() const { return m_symbol; }
|
|
u32 address() const { return m_address; }
|
|
u32 address() const { return m_address; }
|
|
u32 offset() const { return m_offset; }
|
|
u32 offset() const { return m_offset; }
|
|
|
|
+ u64 timestamp() const { return m_timestamp; }
|
|
|
|
|
|
u32 sample_count() const { return m_sample_count; }
|
|
u32 sample_count() const { return m_sample_count; }
|
|
|
|
|
|
@@ -34,7 +35,7 @@ public:
|
|
m_children.append(child);
|
|
m_children.append(child);
|
|
}
|
|
}
|
|
|
|
|
|
- ProfileNode& find_or_create_child(const String& symbol, u32 address, u32 offset)
|
|
|
|
|
|
+ ProfileNode& find_or_create_child(const String& symbol, u32 address, u32 offset, u64 timestamp)
|
|
{
|
|
{
|
|
for (int i = 0; i < m_children.size(); ++i) {
|
|
for (int i = 0; i < m_children.size(); ++i) {
|
|
auto& child = m_children[i];
|
|
auto& child = m_children[i];
|
|
@@ -42,7 +43,7 @@ public:
|
|
return child;
|
|
return child;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- auto new_child = ProfileNode::create(symbol, address, offset);
|
|
|
|
|
|
+ auto new_child = ProfileNode::create(symbol, address, offset, timestamp);
|
|
add_child(new_child);
|
|
add_child(new_child);
|
|
return new_child;
|
|
return new_child;
|
|
};
|
|
};
|
|
@@ -55,10 +56,11 @@ public:
|
|
void sort_children();
|
|
void sort_children();
|
|
|
|
|
|
private:
|
|
private:
|
|
- explicit ProfileNode(const String& symbol, u32 address, u32 offset)
|
|
|
|
|
|
+ explicit ProfileNode(const String& symbol, u32 address, u32 offset, u64 timestamp)
|
|
: m_symbol(symbol)
|
|
: m_symbol(symbol)
|
|
, m_address(address)
|
|
, m_address(address)
|
|
, m_offset(offset)
|
|
, m_offset(offset)
|
|
|
|
+ , m_timestamp(timestamp)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
|
|
|
|
@@ -67,6 +69,7 @@ private:
|
|
u32 m_address { 0 };
|
|
u32 m_address { 0 };
|
|
u32 m_offset { 0 };
|
|
u32 m_offset { 0 };
|
|
u32 m_sample_count { 0 };
|
|
u32 m_sample_count { 0 };
|
|
|
|
+ u64 m_timestamp { 0 };
|
|
Vector<NonnullRefPtr<ProfileNode>> m_children;
|
|
Vector<NonnullRefPtr<ProfileNode>> m_children;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -79,10 +82,24 @@ public:
|
|
|
|
|
|
const Vector<NonnullRefPtr<ProfileNode>>& roots() const { return m_roots; }
|
|
const Vector<NonnullRefPtr<ProfileNode>>& roots() const { return m_roots; }
|
|
|
|
|
|
|
|
+ template<typename Callback>
|
|
|
|
+ void for_each_sample(Callback callback)
|
|
|
|
+ {
|
|
|
|
+ m_json.for_each([&](auto& value) {
|
|
|
|
+ callback(value.as_object());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ u64 length_in_ms() const { return m_last_timestamp - m_first_timestamp; }
|
|
|
|
+ u64 first_timestamp() const { return m_first_timestamp; }
|
|
|
|
+ u64 last_timestamp() const { return m_first_timestamp; }
|
|
|
|
+
|
|
private:
|
|
private:
|
|
- explicit Profile(const JsonArray&, Vector<NonnullRefPtr<ProfileNode>>&&);
|
|
|
|
|
|
+ explicit Profile(const JsonArray&, Vector<NonnullRefPtr<ProfileNode>>&&, u64 first_timestamp, u64 last_timestamp);
|
|
|
|
|
|
JsonArray m_json;
|
|
JsonArray m_json;
|
|
RefPtr<ProfileModel> m_model;
|
|
RefPtr<ProfileModel> m_model;
|
|
Vector<NonnullRefPtr<ProfileNode>> m_roots;
|
|
Vector<NonnullRefPtr<ProfileNode>> m_roots;
|
|
|
|
+ u64 m_first_timestamp { 0 };
|
|
|
|
+ u64 m_last_timestamp { 0 };
|
|
};
|
|
};
|