Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d8ecf5ac9eb8
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 41ba86e3e9c7
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Dec 13, 2019

  1. HistoryWindow: added approximate memory accounting for historical wav…

    …eform data, changed default history cap from 1K to 100 waveforms
    azonenberg committed Dec 13, 2019
    Copy the full SHA
    41ba86e View commit details
Showing with 35 additions and 1 deletion.
  1. +33 −1 glscopeclient/HistoryWindow.cpp
  2. +2 −0 glscopeclient/HistoryWindow.h
34 changes: 33 additions & 1 deletion glscopeclient/HistoryWindow.cpp
Original file line number Diff line number Diff line change
@@ -74,11 +74,14 @@ HistoryWindow::HistoryWindow(OscilloscopeWindow* parent)
m_hbox.pack_start(m_maxLabel, Gtk::PACK_SHRINK);
m_maxLabel.set_label("Max waveforms");
m_hbox.pack_start(m_maxBox, Gtk::PACK_EXPAND_WIDGET);
m_maxBox.set_text("1000");
m_maxBox.set_text("100");
m_vbox.pack_start(m_scroller, Gtk::PACK_EXPAND_WIDGET);
m_scroller.add(m_tree);
m_scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
m_tree.get_selection()->set_mode(Gtk::SELECTION_BROWSE);
m_vbox.pack_start(m_status, Gtk::PACK_SHRINK);
m_status.pack_end(m_memoryLabel, Gtk::PACK_SHRINK);
m_memoryLabel.set_text("");
m_vbox.show_all();

//not shown by default
@@ -175,6 +178,35 @@ void HistoryWindow::OnWaveformDataReady(Oscilloscope* scope)
m_model->erase(it);
}

//Calculate our RAM usage (rough estimate)
size_t bytes_used = 0;
for(auto it : children)
{
WaveformHistory hist = (*it)[m_columns.m_history];
for(auto jt : hist)
{
//TODO: support digital etc captures
auto acap = dynamic_cast<AnalogCapture*>(jt.second);
if(acap == NULL)
continue;

//Add static size of the capture object
bytes_used += sizeof(AnalogCapture);

//Add size of each sample
bytes_used += sizeof(AnalogSample) * acap->GetDepth();
}
}

//Convert to MB/GB
float mb = bytes_used / (1024.0f * 1024.0f);
float gb = mb / 1024;
if(gb > 1)
snprintf(tmp, sizeof(tmp), "Memory: %.2f GB", gb);
else
snprintf(tmp, sizeof(tmp), "Memory: %.0f MB", mb);
m_memoryLabel.set_label(tmp);

m_updating = false;
}

2 changes: 2 additions & 0 deletions glscopeclient/HistoryWindow.h
Original file line number Diff line number Diff line change
@@ -73,6 +73,8 @@ class HistoryWindow : public Gtk::Window
Gtk::ScrolledWindow m_scroller;
Gtk::TreeView m_tree;
Glib::RefPtr<Gtk::TreeStore> m_model;
Gtk::HBox m_status;
Gtk::Label m_memoryLabel;
HistoryColumns m_columns;

OscilloscopeWindow* m_parent;