Debian Codegraph @

sys/praat_statistics.cpp

raw symbols SCIP
1 /* praat_statistics.cpp
2 *
3 * Copyright (C) 1992-2012,2014-2022,2024-2026 Paul Boersma & David Weenink
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <time.h>
20 #include <locale.h>
21 #include <thread>
22 #if defined (macintosh)
23 #include <pwd.h>
24 #endif
25 #include "praatP.h"cxx . . $ `<file>/sys/praatP.h`/
26 #include "GraphicsP.h"cxx . . $ `<file>/sys/GraphicsP.h`/
27 #include "NUMmachar.h"cxx . . $ `<file>/dwsys/NUMmachar.h`/
28
29 static structcxx . . $ $anonymous_type_5b9de7a9b61d05f6_0# {
30 integercxx . . $ integer# batchSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#batchSessions., interactiveSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#interactiveSessions.;
31 double memorycxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#memory.;
32 PrefsStringcxx . . $ PrefsString# dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession.;
33 } statisticscxx . . $ statistics.;
34
35 void praat_statistics_prefscxx . . $ praat_statistics_prefs(49f6e7a06ebc5aa8). () {
36 Preferences_addIntegercxx . . $ Preferences_addInteger(dd1501ba114a3e1c). (U"PraatShell.batchSessions", & statisticscxx . . $ statistics..batchSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#batchSessions., 0);
37 Preferences_addIntegercxx . . $ Preferences_addInteger(dd1501ba114a3e1c). (U"PraatShell.interactiveSessions", & statisticscxx . . $ statistics..interactiveSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#interactiveSessions., 0);
38 Preferences_addDoublecxx . . $ Preferences_addDouble(bd3f288232783655). (U"PraatShell.memory", & statisticscxx . . $ statistics..memorycxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#memory., 0.0);
39 Preferences_addStringcxx . . $ Preferences_addString(ff8f0bc01bc68d7b). (U"PraatShell.dateOfFirstSession", & statisticscxx . . $ statistics..dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession. [0], U"");
40 }
41
42 void praat_statistics_prefsChangedcxx . . $ praat_statistics_prefsChanged(49f6e7a06ebc5aa8). () {
43 if (! statisticscxx . . $ statistics..dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession. [0]) {
44 time_tcxx . . $ time_t# today = time (nullptr);
45 char32cxx . . $ char32# *newLine;
46 str32cpycxx . . $ str32cpy(6ab934322573b179). (statisticscxx . . $ statistics..dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession., Melder_peek8to32_u (ctime (& today)));
47 newLine = str32chrcxx . . $ str32chr(328a9ede0fba853a). (statisticscxx . . $ statistics..dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession., U'\n');
48 if (newLine) *newLine = '\0';
49 }
50 if (theCurrentPraatApplicationcxx . . $ theCurrentPraatApplication. -> batchcxx . . $ structPraatApplication#batch.)
51 statisticscxx . . $ statistics..batchSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#batchSessions. += 1;
52 else
53 statisticscxx . . $ statistics..interactiveSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#interactiveSessions. += 1;
54 }
55
56 void praat_statistics_exitcxx . . $ praat_statistics_exit(49f6e7a06ebc5aa8). () {
57 statisticscxx . . $ statistics..memorycxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#memory. += Melder_allocationSizecxx . . $ Melder_allocationSize(da6335ded91d79c2). ();
58 }
59
60 /*@praat
61 report$ = Report integer properties
62 sizeOfInteger = extractNumber (report$, "An indexing integer is ")
63 sizeOfPointer = extractNumber (report$, "A pointer is ")
64 assert sizeOfInteger = sizeOfPointer
65 sizeOfFileOffset = extractNumber (report$, "A file offset is ")
66 assert sizeOfFileOffset = 64
67 @*/
68 void praat_reportIntegerPropertiescxx . . $ praat_reportIntegerProperties(49f6e7a06ebc5aa8). () {
69 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
70 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Integer properties of this edition of Praat on this computer:\n");
71 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A boolean is ", sizeof (bool) * 8, U" bits.");
72 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"short integer\" is ", sizeof (short) * 8, U" bits.");
73 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"An \"integer\" is ", sizeof (int) * 8, U" bits.");
74 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"long integer\" is ", sizeof (long) * 8, U" bits.");
75 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"long long integer\" is ", sizeof (long long) * 8, U" bits.");
76 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"An indexing integer is ", sizeof (integercxx . . $ integer#) * 8, U" bits.");
77 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A pointer is ", sizeof (void *) * 8, U" bits.");
78 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A memory object size is ", sizeof (size_t) * 8, U" bits.");
79 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A file offset is ", sizeof (off_t) * 8, U" bits.");
80 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
81 }
82
83 void praat_reportFloatingPointPropertiescxx . . $ praat_reportFloatingPointProperties(49f6e7a06ebc5aa8). () {
84 if (! NUMfppcxx . . $ NUMfpp.)
85 NUMmacharcxx . . $ NUMmachar(49f6e7a06ebc5aa8). ();
86 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
87 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Double precision floating point properties of this machine,");
88 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"as calculated by algorithms from the Binary Linear Algebra System (BLAS)");
89 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\nRadix: ", NUMfppcxx . . $ NUMfpp. -> basecxx . . $ structmachar_Table#base.);
90 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of digits in mantissa: ", NUMfppcxx . . $ NUMfpp. -> tcxx . . $ structmachar_Table#t.);
91 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Smallest exponent before (gradual) underflow (expmin): ", NUMfppcxx . . $ NUMfpp. -> emincxx . . $ structmachar_Table#emin.);
92 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Largest exponent before overflow (expmax): ", NUMfppcxx . . $ NUMfpp. -> emaxcxx . . $ structmachar_Table#emax.);
93 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Does rounding occur in addition: ", (NUMfppcxx . . $ NUMfpp. -> rndcxx . . $ structmachar_Table#rnd. == 1 ? U"yes" : U"no"));
94 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Quantization step (d): ", NUMfppcxx . . $ NUMfpp. -> preccxx . . $ structmachar_Table#prec.);
95 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Quantization error (eps = d/2): ", NUMfppcxx . . $ NUMfpp. -> epscxx . . $ structmachar_Table#eps.);
96 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Underflow threshold (= radix ^ (expmin - 1)): ", NUMfppcxx . . $ NUMfpp. -> rmincxx . . $ structmachar_Table#rmin.);
97 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Safe minimum (such that its inverse does not overflow): ", NUMfppcxx . . $ NUMfpp. -> sfmincxx . . $ structmachar_Table#sfmin.);
98 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Overflow threshold (= (1 - eps) * radix ^ expmax): ", NUMfppcxx . . $ NUMfpp. -> rmaxcxx . . $ structmachar_Table#rmax.);
99 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\nA long double is ", sizeof (long double), U" bytes");
100 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A longdouble is ", sizeof (longdoublecxx . . $ longdouble#), U" bytes");
101 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
102 }
103
104 void praat_reportTextPropertiescxx . . $ praat_reportTextProperties(49f6e7a06ebc5aa8). () {
105 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
106 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Text properties of this edition of Praat on this computer:\n");
107 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Locale: ", Melder_peek8to32_u (setlocale (LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, nullptr)));
108 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"char\" is ", 8, U" bits.");
109 constexpr bool charIsSigned = ( (int) (char) 200 < 0 );
110 if (charIsSigned)
111 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"char\" is ", charIsSigned ? U"signed." : U"unsigned.");
112 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"char16_t\" is ", sizeof (char16_t) * 8, U" bits.");
113 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"wchar_t\" is ", sizeof (wchar_t) * 8, U" bits.");
114 if constexpr ((wchar_t) -1 < 0)
115 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"wchar_t\" is signed.");
116 else
117 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"wchar_t\" is unsigned.");
118 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"A \"char32_t\" is ", sizeof (char32_t) * 8, U" bits.");
119 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
120 }
121
122 #if defined (macintosh)
123 static bool isSandboxed () {
124 //return !! NSProcessInfo.processInfo.environment [@"APP_SANDBOX_CONTAINER_ID"];
125 return !! Melder_getenv (U"APP_SANDBOX_CONTAINER_ID");
126 }
127 static kleenean hasFullDiskAccess () {
128 if (Melder_systemVersion < 101400)
129 return kleenean_YES;
130 NSFileManager *nsFileManager = [NSFileManager defaultManager];
131 //NSWorkspace *nsWorkspace = [NSWorkspace sharedWorkspace];
132 // to open the preferences at Full Disk Access: [nsWorkspace openURL: [NSURL URLWithString: @"x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"]];
133 NSString *nsUserHomeFolderPath;
134 if (isSandboxed ()) {
135 struct passwd *password = getpwuid (getuid ());
136 Melder_assert (!! password);
137 nsUserHomeFolderPath = [NSString stringWithUTF8String: password -> pw_dir];
138 } else {
139 nsUserHomeFolderPath = NSHomeDirectory ();
140 }
141 NSString *perhapsUnreadableFilePath = ( Melder_systemVersion < 101500 ?
142 [nsUserHomeFolderPath stringByAppendingPathComponent: @"Library/Safari/Bookmarks.plist"] :
143 [nsUserHomeFolderPath stringByAppendingPathComponent: @"Library/Safari/CloudTabs.db"]
144 );
145 structMelderFile file { };
146 Melder_pathToFile (Melder_peek8to32_u ([perhapsUnreadableFilePath UTF8String]), & file);
147 if (! MelderFile_exists (& file))
148 return kleenean_UNKNOWN;
149 if (! MelderFile_readable (& file))
150 return kleenean_NO;
151 return kleenean_YES;
152 }
153 static NSString *getRealHomeDirectory () {
154 NSString *nsUserHomeFolderPath;
155 if (isSandboxed ()) {
156 struct passwd *password = getpwuid (getuid ());
157 Melder_assert (!! password);
158 nsUserHomeFolderPath = [NSString stringWithUTF8String: password -> pw_dir];
159 } else {
160 nsUserHomeFolderPath = NSHomeDirectory ();
161 }
162 return nsUserHomeFolderPath;
163 }
164 #endif // defined (macintosh)
165
166 void praat_reportSystemPropertiescxx . . $ praat_reportSystemProperties(49f6e7a06ebc5aa8). () {
167 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
168 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"System properties of this edition of Praat on this computer:\n");
169 #ifdef _WIN32
170 MelderInfo_writeLine (U"_WIN32 is \"" stringize(_WIN32) "\".");
171 #endif
172 #ifdef WINVER
173 MelderInfo_writeLine (U"WINVER is \"" stringize(WINVER) "\".");
174 #endif
175 #ifdef _WIN32_WINNT
176 MelderInfo_writeLine (U"_WIN32_WINNT is \"" stringize(_WIN32_WINNT) "\".");
177 #endif
178 #ifdef _WIN32_IE
179 MelderInfo_writeLine (U"_WIN32_IE is \"" stringize(_WIN32_IE) "\".");
180 #endif
181 #ifdef UNICODE
182 MelderInfo_writeLine (U"UNICODE is \"" stringize(UNICODE) "\".");
183 #endif
184 #ifdef _FILE_OFFSET_BITScxx . . $ `<built-in>:481:9`!
185 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"_FILE_OFFSET_BITS is \"" stringizecxx . . $ `melder/melder.h:58:9`!(_FILE_OFFSET_BITScxx . . $ `<built-in>:481:9`!) "\".");
186 #endif
187 #ifdef macintosh
188 MelderInfo_writeLine (U"macintosh is \"" stringize(macintosh) "\".");
189 #endif
190 #ifdef linuxcxx . . $ `<built-in>:480:9`!
191 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"linux is \"" stringizecxx . . $ `melder/melder.h:58:9`!(linuxcxx . . $ `<built-in>:480:9`!) "\".");
192 #endif
193 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Maximum number of concurrent threads: ", stdcxx . . $ std/::threadcxx . . $ std/thread#::hardware_concurrencycxx . . $ std/thread#hardware_concurrency(2658d6455debfaef).(), U".");
194 #ifdef macintosh
195 MelderInfo_writeLine (U"system version is ", Melder_systemVersion, U".");
196 #endif
197 #ifdef linuxcxx . . $ `<built-in>:480:9`!
198 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Display protocol: probably ", Melder_systemVersioncxx . . $ Melder_systemVersion. == 'w' ? U"Wayland" : U"X11", U" (but use xeyes to make sure).");
199 #endif
200 #if defined (__aarch64__) || defined (_M_ARM64_)
201 MelderInfo_writeLine (U"Built for processor type: ", U"arm64");
202 #elif defined (__s390x__)
203 MelderInfo_writeLine (U"Built for processor type: ", U"s390x");
204 #elif defined (raspberrypi)
205 MelderInfo_writeLine (U"Built for processor type: ", U"armv7");
206 #else
207 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Built for processor type: ", sizeof (void *) == 4 ? U"intel32" : U"intel64");
208 #endif
209 #if defined (__ARM_ARCH)
210 MelderInfo_writeLine (U"__ARM_ARCH: defined");
211 #else
212 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"__ARM_ARCH: undefined");
213 #endif
214 #if defined (__ARM_NEON)
215 MelderInfo_writeLine (U"__ARM_NEON: defined");
216 #else
217 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"__ARM_NEON: undefined");
218 #endif
219 structMelderFoldercxx . . $ structMelderFolder# homeFolder {};
220 Melder_getHomeDircxx . . $ Melder_getHomeDir(63f38d3b6b86d1dc). (& homeFolder);
221 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Home folder: ", MelderFolder_peekPathcxx . . $ MelderFolder_peekPath(fbe3b4f4d15c56ee). (& homeFolder));
222 #ifdef macintosh
223 MelderInfo_writeLine (U"Full Disk Access: ", Melder_kleenean (hasFullDiskAccess ()));
224 MelderInfo_writeLine (U"Sandboxed: ", Melder_boolean (isSandboxed ()));
225 if (isSandboxed ())
226 MelderInfo_writeLine (U"Sandbox (application home) folder: ", Melder_peek8to32_u ([NSHomeDirectory () UTF8String]));
227 MelderInfo_writeLine (U"User home folder: ", Melder_peek8to32_u ([getRealHomeDirectory () UTF8String]));
228 NSRunningApplication *currentApplication = [NSRunningApplication currentApplication];
229 pid_t processID = [currentApplication processIdentifier];
230 Melder_assert (processID == getpid());
231 MelderInfo_writeLine (U"Process ID: ", processID);
232 MelderInfo_writeLine (U"Localized app name: ", Melder_peek8to32_u ([[currentApplication localizedName] UTF8String]));
233 MelderInfo_writeLine (U"App bundle identifier: ", Melder_peek8to32_u ([[currentApplication bundleIdentifier] UTF8String]));
234 #endif // macintosh
235 #ifdef _WIN32
236 MelderInfo_writeLine (U"SM_CXFIXEDFRAME: ", GetSystemMetrics (SM_CXFIXEDFRAME));
237 MelderInfo_writeLine (U"SM_CYFIXEDFRAME: ", GetSystemMetrics (SM_CYFIXEDFRAME));
238 MelderInfo_writeLine (U"SM_CXSIZEFRAME: ", GetSystemMetrics (SM_CXSIZEFRAME));
239 MelderInfo_writeLine (U"SM_CYSIZEFRAME: ", GetSystemMetrics (SM_CYSIZEFRAME));
240 MelderInfo_writeLine (U"SM_CYCAPTION: ", GetSystemMetrics (SM_CYCAPTION));
241 MelderInfo_writeLine (U"SM_CYMENU: ", GetSystemMetrics (SM_CYMENU));
242 #endif // _WIN32
243 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
244 }
245
246 void praat_reportAppPropertiescxx . . $ praat_reportAppProperties(49f6e7a06ebc5aa8). () {
247 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
248 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Upper-case app name: ", Melder_upperCaseAppNamecxx . . $ Melder_upperCaseAppName(1912f6684645c851).());
249 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Lower-case app name: ", Melder_lowerCaseAppNamecxx . . $ Melder_lowerCaseAppName(1912f6684645c851).());
250 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App version (as a number): ", Melder_appVersioncxx . . $ Melder_appVersion(da6335ded91d79c2).());
251 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App version (as text): ", Melder_appVersionSTRcxx . . $ Melder_appVersionSTR(1912f6684645c851).());
252 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App year: ", Melder_appYearcxx . . $ Melder_appYear(da6335ded91d79c2).());
253 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App month (as a number): ", Melder_appMonthcxx . . $ Melder_appMonth(da6335ded91d79c2).());
254 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App month (as text): ", Melder_appMonthSTRcxx . . $ Melder_appMonthSTR(1912f6684645c851).());
255 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App day: ", Melder_appDaycxx . . $ Melder_appDay(da6335ded91d79c2).());
256 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"App contact address: ", Melder_appContactAddresscxx . . $ Melder_appContactAddress(1912f6684645c851).());
257 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
258 }
259
260 void praat_reportGraphicalPropertiescxx . . $ praat_reportGraphicalProperties(49f6e7a06ebc5aa8). () {
261 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
262 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Graphical properties of this edition of Praat on this computer:\n");
263 double x, y, width, height;
264 Gui_getWindowPositioningBoundscxx . . $ Gui_getWindowPositioningBounds(dec26d86168e59a). (& x, & y, & width, & height);
265 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Window positioning area: x = ", x, U", y = ", y,
266 U", width = ", width, U", height = ", height);
267 #if defined (macintosh)
268 CGDirectDisplayID screen = CGMainDisplayID ();
269 CGSize screenSize_mm = CGDisplayScreenSize (screen);
270 const double diagonal_mm = hypot (screenSize_mm. width, screenSize_mm. height);
271 const double diagonal_inch = diagonal_mm / 25.4;
272 MelderInfo_writeLine (U"\nScreen size: ", screenSize_mm. width, U" x ", screenSize_mm. height,
273 U" mm (diagonal ", Melder_fixed (diagonal_mm, 1), U" mm = ", Melder_fixed (diagonal_inch, 1), U" inch)");
274 const size_t screenWidth_pixels = CGDisplayPixelsWide (screen);
275 const size_t screenHeight_pixels = CGDisplayPixelsHigh (screen);
276 MelderInfo_writeLine (U"Screen \"resolution\": ", screenWidth_pixels, U" x ", screenHeight_pixels, U" pixels");
277 const double resolution = 25.4 * screenWidth_pixels / screenSize_mm. width;
278 MelderInfo_writeLine (U"Screen resolution: ", Melder_fixed (resolution, 1), U" pixels/inch");
279 #elif defined (_WIN32)
280 /*for (int i = 0; i <= 88; i ++)
281 MelderInfo_writeLine (U"System metric ", i, U": ", GetSystemMetrics (i));*/
282 #endif
283 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
284 }
285
286 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
287 static void testFontcxx . . $ testFont(8e5bbe1ea2134402). (PangoFontMap *pangoFontMap, PangoContext *pangoContext, conststring32cxx . . $ conststring32# fontName) {
288 PangoFontDescription *pangoFontDescription = pango_font_description_from_string (Melder_peek32to8 (fontName));
289 PangoFont *pangoFont = pango_font_map_load_font (pangoFontMap, pangoContext, pangoFontDescription);
290 PangoFontDescription *pangoFontDescription2 = pango_font_describe (pangoFont);
291 const char *familyName = pango_font_description_get_family (pangoFontDescription2);
292 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Asking for font ", fontName, U" gives ", Melder_peek8to32_u (familyName), U".");
293 }
294 #endif // cairo
295 void praat_reportFontPropertiescxx . . $ praat_reportFontProperties(49f6e7a06ebc5aa8). () {
296 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
297 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Font replacement on this computer:\n");
298 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
299 PangoFontMap *pangoFontMap = pango_cairo_font_map_get_default ();
300 PangoContext *pangoContext = pango_font_map_create_context (pangoFontMap);
301 conststring32cxx . . $ conststring32# fontNames [] = { U"Times", U"Roman", U"Serif",
302 U"Helvetica", U"Arial", U"Sans",
303 U"Courier", U"Courier New", U"Mono", U"Monospace",
304 U"Palatino", U"Palladio",
305 U"Doulos", U"Doulos SIL", U"Charis", U"Charis SIL",
306 U"Symbol", U"Dingbats",
307 nullptr
308 };
309 for (conststring32cxx . . $ conststring32# *fontName = & fontNames [0]; !! *fontName; fontName ++)
310 testFontcxx . . $ testFont(8e5bbe1ea2134402). (pangoFontMap, pangoContext, *fontName);
311 g_object_unref (pangoContext);
312
313 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\nAll fonts on this computer:\n");
314 PangoFontFamily **families;
315 int numberOfFamilies;
316 pango_font_map_list_families (pangoFontMap, & families, & numberOfFamilies);
317 for (int i = 0; i < numberOfFamilies; i ++)
318 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (i, U" ", Melder_peek8to32_u (pango_font_family_get_name (families [i])));
319 g_free (families);
320 #endif // cairo
321 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
322 }
323
324 void praat_reportMemoryUsecxx . . $ praat_reportMemoryUse(49f6e7a06ebc5aa8). () {
325 MelderInfo_opencxx . . $ MelderInfo_open(49f6e7a06ebc5aa8). ();
326 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Memory use by Praat:\n");
327 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Currently in use:\n"
328 U" Strings: ", MelderString_allocationCountcxx . . $ MelderString_allocationCount(da6335ded91d79c2). () - MelderString_deallocationCountcxx . . $ MelderString_deallocationCount(da6335ded91d79c2). (),
329 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderString_allocationSizecxx . . $ MelderString_allocationSize(da6335ded91d79c2). () - MelderString_deallocationSizecxx . . $ MelderString_deallocationSize(da6335ded91d79c2). ()), U" characters)");
330 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
331 U" Arrays: ", MelderArray_allocationCountcxx . . $ MelderArray_allocationCount(da6335ded91d79c2). () - MelderArray_deallocationCountcxx . . $ MelderArray_deallocationCount(da6335ded91d79c2). (),
332 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderArray_cellAllocationCountcxx . . $ MelderArray_cellAllocationCount(da6335ded91d79c2). () - MelderArray_cellDeallocationCountcxx . . $ MelderArray_cellDeallocationCount(da6335ded91d79c2). ()), U" cells)");
333 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Things: ", theTotalNumberOfThingscxx . . $ theTotalNumberOfThings. + 0,
334 U" (objects in list: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. -> ncxx . . $ structPraatObjects#n.), U")");
335 integercxx . . $ integer# numberOfMotifWidgets =
336 #if motifcxx . . $ `sys/Gui.h:34:10`!
337 Gui_getNumberOfMotifWidgets ();
338 MelderInfo_writeLine (U" Motif widgets: ", Melder_bigInteger (numberOfMotifWidgets));
339 #else
340 0;
341 #endif
342 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Other: ",
343 Melder_allocationCountcxx . . $ Melder_allocationCount(da6335ded91d79c2). () - Melder_deallocationCountcxx . . $ Melder_deallocationCount(da6335ded91d79c2). ()
344 - theTotalNumberOfThingscxx . . $ theTotalNumberOfThings.
345 - (MelderString_allocationCountcxx . . $ MelderString_allocationCount(da6335ded91d79c2). () - MelderString_deallocationCountcxx . . $ MelderString_deallocationCount(da6335ded91d79c2). ())
346 - (MelderArray_allocationCountcxx . . $ MelderArray_allocationCount(da6335ded91d79c2). () - MelderArray_deallocationCountcxx . . $ MelderArray_deallocationCount(da6335ded91d79c2). ())
347 - numberOfMotifWidgets
348 );
349 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
350 U"\nMemory history of this session:\n"
351 U" Total created: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (Melder_allocationCountcxx . . $ Melder_allocationCount(da6335ded91d79c2). ()), U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (Melder_allocationSizecxx . . $ Melder_allocationSize(da6335ded91d79c2). ()), U" bytes)");
352 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Total deleted: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (Melder_deallocationCountcxx . . $ Melder_deallocationCount(da6335ded91d79c2). ()));
353 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Reallocations: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (Melder_movingReallocationsCountcxx . . $ Melder_movingReallocationsCount(da6335ded91d79c2). ()), U" moving, ",
354 Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (Melder_reallocationsInSituCountcxx . . $ Melder_reallocationsInSituCount(da6335ded91d79c2). ()), U" in situ");
355 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
356 U" Strings created: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderString_allocationCountcxx . . $ MelderString_allocationCount(da6335ded91d79c2). ()),
357 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderString_allocationSizecxx . . $ MelderString_allocationSize(da6335ded91d79c2). ()), U" characters)");
358 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
359 U" Strings deleted: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderString_deallocationCountcxx . . $ MelderString_deallocationCount(da6335ded91d79c2). ()),
360 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderString_deallocationSizecxx . . $ MelderString_deallocationSize(da6335ded91d79c2). ()), U" characters)");
361 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
362 U" Arrays created: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderArray_allocationCountcxx . . $ MelderArray_allocationCount(da6335ded91d79c2). ()),
363 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderArray_cellAllocationCountcxx . . $ MelderArray_cellAllocationCount(da6335ded91d79c2). ()), U" cells)");
364 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (
365 U" Arrays deleted: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderArray_deallocationCountcxx . . $ MelderArray_deallocationCount(da6335ded91d79c2). ()),
366 U" (", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (MelderArray_cellDeallocationCountcxx . . $ MelderArray_cellDeallocationCount(da6335ded91d79c2). ()), U" cells)");
367 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\nHistory of all sessions from ", statisticscxx . . $ statistics..dateOfFirstSessioncxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#dateOfFirstSession., U" until today:");
368 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Sessions: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (statisticscxx . . $ statistics..interactiveSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#interactiveSessions.), U" interactive, ",
369 Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (statisticscxx . . $ statistics..batchSessionscxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#batchSessions.), U" batch");
370 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Total memory use: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). ((int64cxx . . $ int64#) statisticscxx . . $ statistics..memorycxx . . $ $anonymous_type_5b9de7a9b61d05f6_0#memory. + Melder_allocationSizecxx . . $ Melder_allocationSize(da6335ded91d79c2). ()), U" bytes");
371 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"\nNumber of fixed menu commands: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (praat_getNumberOfMenuCommandscxx . . $ praat_getNumberOfMenuCommands(da6335ded91d79c2). ()));
372 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of dynamic menu commands: ", Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (praat_getNumberOfActionscxx . . $ praat_getNumberOfActions(da6335ded91d79c2). ()));
373 MelderInfo_closecxx . . $ MelderInfo_close(49f6e7a06ebc5aa8). ();
374 }
375
376 void MelderCasual_memoryUsecxx . . $ MelderCasual_memoryUse(1624ee8275b10bda). (integercxx . . $ integer# message) {
377 integercxx . . $ integer# numberOfStrings = MelderString_allocationCountcxx . . $ MelderString_allocationCount(da6335ded91d79c2). () - MelderString_deallocationCountcxx . . $ MelderString_deallocationCount(da6335ded91d79c2). ();
378 integercxx . . $ integer# numberOfArrays = MelderArray_allocationCountcxx . . $ MelderArray_allocationCount(da6335ded91d79c2). () - MelderArray_deallocationCountcxx . . $ MelderArray_deallocationCount(da6335ded91d79c2). ();
379 integercxx . . $ integer# numberOfThings = theTotalNumberOfThingscxx . . $ theTotalNumberOfThings.;
380 integercxx . . $ integer# numberOfOther = Melder_allocationCountcxx . . $ Melder_allocationCount(da6335ded91d79c2). () - Melder_deallocationCountcxx . . $ Melder_deallocationCount(da6335ded91d79c2). ()
381 - numberOfStrings - numberOfArrays - numberOfThings;
382 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"Memory ", message, U": ",
383 numberOfStrings, U" strings, ", numberOfArrays, U" arrays, ", numberOfThings, U" things, ", numberOfOther, U" other.");
384 }
385
386 /* End of file praat_statistics.cpp */