[gnome-disk-utility] gdubenchmarkdialog: Add settings schema for benchmark settings
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] gdubenchmarkdialog: Add settings schema for benchmark settings
- Date: Fri, 13 Aug 2021 17:43:00 +0000 (UTC)
commit 4dcc56cfdc44eca2166ce7836addef7d95d21ecd
Author: Manuel Wassermann <manuel wassermann97 gmail com>
Date: Sat Jul 17 21:36:34 2021 +0200
gdubenchmarkdialog: Add settings schema for benchmark settings
The settings for a new benchmark are always reset to default, therefore
it is not very friendly to test different devices with the same settings.
Add GSettings schema to save the last used settings.
data/org.gnome.Disks.gschema.xml | 18 ++++++++++++++++++
src/disks/gdubenchmarkdialog.c | 18 ++++++++++++++++++
2 files changed, 36 insertions(+)
---
diff --git a/data/org.gnome.Disks.gschema.xml b/data/org.gnome.Disks.gschema.xml
index 35cb06ce..859f6fc2 100644
--- a/data/org.gnome.Disks.gschema.xml
+++ b/data/org.gnome.Disks.gschema.xml
@@ -7,4 +7,22 @@
<description>Default location for the Create/Restore disk image dialogs. If blank the ~/Documents
folder is used.</description>
</key>
</schema>
+ <schema id="org.gnome.Disks.benchmark" path="/org/gnome/Disks/benchmark/"
gettext-domain="gnome-disk-utility">
+ <key name="num-samples" type="i">
+ <default>100</default>
+ <summary>The number of samples the benchmark will include for the read/write test.</summary>
+ </key>
+ <key name="sample-size-mib" type="i">
+ <default>10</default>
+ <summary>The number of MiB (1048576 bytes) to read/write for each sample.</summary>
+ </key>
+ <key name="do-write" type="b">
+ <default>true</default>
+ <summary>To enable or disable the write test.</summary>
+ </key>
+ <key name="num-access-samples" type="i">
+ <default>1000</default>
+ <summary>The number of samples the benchmark will do for the access time test.</summary>
+ </key>
+ </schema>
</schemalist>
diff --git a/src/disks/gdubenchmarkdialog.c b/src/disks/gdubenchmarkdialog.c
index 2db957ea..e975614d 100644
--- a/src/disks/gdubenchmarkdialog.c
+++ b/src/disks/gdubenchmarkdialog.c
@@ -1517,6 +1517,7 @@ start_benchmark (DialogData *data)
GtkWidget *sample_size_spinbutton;
GtkWidget *write_checkbutton;
GtkWidget *num_access_samples_spinbutton;
+ GSettings *settings;
gint response;
g_assert (!data->bm_in_progress);
@@ -1535,6 +1536,17 @@ start_benchmark (DialogData *data)
write_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "write-checkbutton"));
num_access_samples_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder,
"num-access-samples-spinbutton"));
+ settings = g_settings_new ("org.gnome.Disks.benchmark");
+ data->bm_num_samples = g_settings_get_int (settings, "num-samples");
+ data->bm_sample_size_mib = g_settings_get_int (settings, "sample-size-mib");
+ data->bm_do_write = g_settings_get_boolean (settings, "do-write");
+ data->bm_num_access_samples = g_settings_get_int (settings, "num-access-samples");
+
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(num_samples_spinbutton), data->bm_num_samples);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(sample_size_spinbutton), data->bm_sample_size_mib);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (write_checkbutton), data->bm_do_write);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON(num_access_samples_spinbutton), data->bm_num_access_samples);
+
/* if device is read-only, uncheck the "perform write-test"
* check-button and also make it insensitive
*/
@@ -1563,6 +1575,11 @@ start_benchmark (DialogData *data)
data->bm_do_write = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (write_checkbutton));
data->bm_num_access_samples = gtk_spin_button_get_value (GTK_SPIN_BUTTON (num_access_samples_spinbutton));
+ g_settings_set_int (settings, "num-samples", data->bm_num_samples);
+ g_settings_set_int (settings, "sample-size-mib", data->bm_sample_size_mib);
+ g_settings_set_boolean (settings, "do-write", data->bm_do_write);
+ g_settings_set_int (settings, "num-access-samples", data->bm_num_access_samples);
+
//g_print ("num_samples=%d\n", data->bm_num_samples);
//g_print ("sample_size=%d MB\n", data->bm_sample_size_mib);
//g_print ("do_write=%d\n", data->bm_do_write);
@@ -1585,6 +1602,7 @@ start_benchmark (DialogData *data)
out:
gtk_widget_destroy (dialog);
g_clear_object (&builder);
+ g_clear_object (&settings);
update_dialog (data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]