diff --git a/testsuites/smptests/smplock01/init.c b/testsuites/smptests/smplock01/init.c
index d000a13b8f..2defa2b5c0 100644
--- a/testsuites/smptests/smplock01/init.c
+++ b/testsuites/smptests/smplock01/init.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
- * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG
+ * Copyright (C) 2013, 2024 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,6 +47,8 @@ const char rtems_test_name[] = "SMPLOCK 1";
typedef struct {
rtems_test_parallel_context base;
+ const char *test_sep;
+ const char *counter_sep;
unsigned long counter[TEST_COUNT];
unsigned long local_counter[CPU_COUNT][TEST_COUNT][CPU_COUNT];
SMP_lock_Control lock RTEMS_ALIGNED(CPU_CACHE_LINE_BYTES);
@@ -84,40 +86,69 @@ static rtems_interval test_init(
return test_duration();
}
+static const rtems_test_parallel_job test_jobs[TEST_COUNT];
+
static void test_fini(
test_context *ctx,
- const char *name,
+ const char *lock_type,
+ bool global_lock,
+ const char *section_type,
size_t test,
size_t active_workers
)
{
+ bool cascade = test_jobs[test].cascade;
unsigned long sum = 0;
- unsigned long n = active_workers;
- unsigned long i;
+ const char *value_sep;
+ size_t i;
- printf(" <%s activeWorker=\"%lu\">\n", name, n);
+ if (active_workers == 1 || !cascade) {
+ printf(
+ "%s{\n"
+ " \"lock-type\": \"%s\",\n"
+ " \"lock-object\": \"%s\",\n"
+ " \"section-type\": \"%s\",\n"
+ " \"results\": [",
+ ctx->test_sep,
+ lock_type,
+ global_lock ? "global" : "local",
+ section_type
+ );
+ ctx->test_sep = ", ";
+ ctx->counter_sep = "\n ";
+ }
- for (i = 0; i < n; ++i) {
+ printf(
+ "%s{\n"
+ " \"counter\": [", ctx->counter_sep);
+ ctx->counter_sep = "\n }, ";
+ value_sep = "";
+
+ for (i = 0; i < active_workers; ++i) {
unsigned long local_counter =
ctx->local_counter[active_workers - 1][test][i];
sum += local_counter;
printf(
- " %lu\n",
- i,
+ "%s%lu",
+ value_sep,
local_counter
);
+ value_sep = ", ";
}
printf(
- " %lu\n"
- " %lu\n"
- " %s>\n",
+ "],\n"
+ " \"global-counter\": %lu,\n"
+ " \"sum-of-local-counter\": %lu",
ctx->counter[test],
- sum,
- name
+ sum
);
+
+ if (active_workers == rtems_scheduler_get_processor_maximum() || !cascade) {
+ printf("\n }\n ]\n }");
+ }
}
static void test_0_body(
@@ -151,7 +182,9 @@ static void test_0_fini(
test_fini(
ctx,
- "GlobalTicketLockWithLocalCounter",
+ "Ticket Lock",
+ true,
+ "local counter",
0,
active_workers
);
@@ -188,7 +221,9 @@ static void test_1_fini(
test_fini(
ctx,
- "GlobalMCSLockWithLocalCounter",
+ "MCS Lock",
+ true,
+ "local counter",
1,
active_workers
);
@@ -226,7 +261,9 @@ static void test_2_fini(
test_fini(
ctx,
- "GlobalTicketLockWithGlobalCounter",
+ "Ticket Lock",
+ true,
+ "global counter",
2,
active_workers
);
@@ -264,7 +301,9 @@ static void test_3_fini(
test_fini(
ctx,
- "GlobalMCSLockWithGlobalCounter",
+ "MCS Lock",
+ true,
+ "global counter",
3,
active_workers
);
@@ -306,7 +345,9 @@ static void test_4_fini(
test_fini(
ctx,
- "LocalTicketLockWithLocalCounter",
+ "Ticket Lock",
+ false,
+ "local counter",
4,
active_workers
);
@@ -353,7 +394,9 @@ static void test_5_fini(
test_fini(
ctx,
- "LocalMCSLockWithLocalCounter",
+ "MCS Lock",
+ false,
+ "local counter",
5,
active_workers
);
@@ -399,7 +442,9 @@ static void test_6_fini(
test_fini(
ctx,
- "LocalTicketLockWithGlobalCounter",
+ "Ticket Lock",
+ false,
+ "global counter",
6,
active_workers
);
@@ -450,7 +495,9 @@ static void test_7_fini(
test_fini(
ctx,
- "LocalMCSLockWithGlobalCounter",
+ "MCS Lock",
+ false,
+ "global counter",
7,
active_workers
);
@@ -497,7 +544,9 @@ static void test_8_fini(
test_fini(
ctx,
- "GlobalTicketLockWithBusySection",
+ "Ticket Lock",
+ true,
+ "busy loop",
8,
active_workers
);
@@ -535,7 +584,9 @@ static void test_9_fini(
test_fini(
ctx,
- "GlobalMCSLockWithBusySection",
+ "MCS Lock",
+ true,
+ "busy loop",
9,
active_workers
);
@@ -595,7 +646,9 @@ static void test_10_fini(
test_fini(
ctx,
- "SequenceLock",
+ "Sequence Lock",
+ true,
+ "two global counter",
10,
active_workers
);
@@ -634,7 +687,9 @@ static void test_11_fini(
test_fini(
ctx,
- "GlobalTASLockWithLocalCounter",
+ "TAS Lock",
+ true,
+ "local counter",
11,
active_workers
);
@@ -675,7 +730,9 @@ static void test_12_fini(
test_fini(
ctx,
- "GlobalTTASLockWithLocalCounter",
+ "TTAS Lock",
+ true,
+ "local counter",
12,
active_workers
);
@@ -753,11 +810,11 @@ static const rtems_test_parallel_job test_jobs[TEST_COUNT] = {
static void test(void)
{
test_context *ctx = &test_instance;
- const char *test = "SMPLock01";
- printf("<%s>\n", test);
+ printf("*** BEGIN OF JSON DATA ***\n[\n ");
+ ctx->test_sep = "";
rtems_test_parallel(&ctx->base, NULL, &test_jobs[0], TEST_COUNT);
- printf("%s>\n", test);
+ printf("\n]\n*** END OF JSON DATA ***\n");
}
static void Init(rtems_task_argument arg)
diff --git a/testsuites/smptests/smplock01/smplock01.scn b/testsuites/smptests/smplock01/smplock01.scn
index 3d4b90f507..1d2e3c98e1 100644
--- a/testsuites/smptests/smplock01/smplock01.scn
+++ b/testsuites/smptests/smplock01/smplock01.scn
@@ -1,2576 +1,239 @@
+
+ SIS - SPARC/RISCV instruction simulator 2.30, copyright Jiri Gaisler 2020
+ Bug-reports to jiri@gaisler.se
+
+ GR740/LEON4 emulation enabled, 4 cpus online, delta 50 clocks
+
+ Loaded build/sparc/gr740/testsuites/smptests/smplock01.exe, entry 0x00000000
+
+
*** BEGIN OF TEST SMPLOCK 1 ***
-
-
- 18357037
- 0
- 18357037
-
-
- 10121166
- 10121320
- 0
- 20242486
-
-
- 5707325
- 5707356
- 5707357
- 0
- 17122038
-
-
- 4194779
- 4194794
- 4194790
- 4194794
- 0
- 16779157
-
-
- 3328106
- 3328112
- 3328107
- 3328109
- 3328114
- 0
- 16640548
-
-
- 2719456
- 2719464
- 2719465
- 2719465
- 2719465
- 2719464
- 0
- 16316779
-
-
- 2281694
- 2281698
- 2281695
- 2281700
- 2281700
- 2281697
- 2281699
- 0
- 15971883
-
-
- 1973749
- 1973751
- 1973749
- 1973754
- 1973753
- 1973751
- 1973749
- 1973749
- 0
- 15790005
-
-
- 531562
- 531561
- 531558
- 531556
- 531562
- 531566
- 531561
- 531560
- 531589
- 0
- 4784075
-
-
- 467120
- 467127
- 467117
- 467120
- 467123
- 467116
- 467122
- 467116
- 467180
- 467179
- 0
- 4671320
-
-
- 426740
- 426739
- 426742
- 426737
- 426740
- 426741
- 426747
- 426735
- 426768
- 426765
- 426767
- 0
- 4694221
-
-
- 388705
- 388703
- 388710
- 388706
- 388701
- 388702
- 388702
- 388705
- 388740
- 388739
- 388740
- 388739
- 0
- 4664592
-
-
- 356920
- 356917
- 356916
- 356917
- 356920
- 356919
- 356920
- 356917
- 356948
- 356947
- 356948
- 356947
- 356953
- 0
- 4640089
-
-
- 330192
- 330192
- 330186
- 330185
- 330190
- 330183
- 330187
- 330187
- 330226
- 330225
- 330225
- 330228
- 330225
- 330226
- 0
- 4622857
-
-
- 303180
- 303186
- 303190
- 303180
- 303188
- 303181
- 303183
- 303191
- 303199
- 303204
- 303209
- 303207
- 303212
- 303215
- 303217
- 0
- 4547942
-
-
- 274980
- 274975
- 274979
- 274983
- 274979
- 274977
- 274974
- 274980
- 274977
- 274984
- 274983
- 274981
- 274982
- 274978
- 274980
- 274977
- 0
- 4399669
-
-
- 261695
- 261697
- 261696
- 261696
- 261694
- 261695
- 261697
- 261692
- 261696
- 261692
- 261696
- 261697
- 261697
- 261695
- 261692
- 261691
- 261708
- 0
- 4448826
-
-
- 240007
- 240008
- 240007
- 240008
- 240010
- 240007
- 240006
- 240008
- 240008
- 240007
- 240010
- 240007
- 240010
- 240007
- 240007
- 240010
- 240020
- 240017
- 0
- 4320164
-
-
- 225896
- 225897
- 225897
- 225898
- 225899
- 225898
- 225898
- 225896
- 225896
- 225896
- 225897
- 225898
- 225900
- 225899
- 225895
- 225894
- 225906
- 225905
- 225907
- 0
- 4292072
-
-
- 214338
- 214338
- 214338
- 214336
- 214338
- 214337
- 214335
- 214337
- 214338
- 214337
- 214337
- 214338
- 214337
- 214337
- 214339
- 214338
- 214343
- 214343
- 214345
- 214345
- 0
- 4286774
-
-
- 198227
- 198229
- 198227
- 198228
- 198228
- 198229
- 198229
- 198228
- 198227
- 198230
- 198227
- 198228
- 198229
- 198230
- 198228
- 198230
- 198231
- 198232
- 198233
- 198233
- 198232
- 0
- 4162815
-
-
- 192321
- 192322
- 192322
- 192323
- 192325
- 192324
- 192323
- 192324
- 192325
- 192325
- 192323
- 192323
- 192323
- 192323
- 192324
- 192324
- 192329
- 192326
- 192325
- 192329
- 192326
- 192327
- 0
- 4231136
-
-
- 177893
- 177892
- 177895
- 177894
- 177892
- 177891
- 177893
- 177893
- 177893
- 177893
- 177894
- 177894
- 177893
- 177893
- 177894
- 177894
- 177895
- 177895
- 177896
- 177897
- 177894
- 177896
- 177894
- 0
- 4091558
-
-
- 168726
- 168726
- 168726
- 168726
- 168726
- 168725
- 168726
- 168726
- 168726
- 168726
- 168728
- 168727
- 168727
- 168726
- 168726
- 168728
- 168727
- 168729
- 168726
- 168725
- 168728
- 168727
- 168726
- 168726
- 0
- 4049435
-
-
- 13090449
- 0
- 13090449
-
-
- 6384726
- 6384887
- 0
- 12769613
-
-
- 2955420
- 2955434
- 2955434
- 0
- 8866288
-
-
- 2866696
- 2866710
- 2866711
- 2866708
- 0
- 11466825
-
-
- 2996690
- 2996699
- 2996701
- 2996698
- 2996701
- 0
- 14983489
-
-
- 2540852
- 2540864
- 2540864
- 2540862
- 2540861
- 2540863
- 0
- 15245166
-
-
- 2182035
- 2182054
- 2182053
- 2182053
- 2182053
- 2182055
- 2182055
- 0
- 15274358
-
-
- 1920366
- 1920373
- 1920374
- 1920373
- 1920371
- 1920374
- 1920373
- 1920372
- 0
- 15362976
-
-
- 1216597
- 1216602
- 1216602
- 1216602
- 1216601
- 1216602
- 1216603
- 1216601
- 1216600
- 0
- 10949410
-
-
- 1007168
- 1007170
- 1007171
- 1007170
- 1007170
- 1007170
- 1007171
- 1007170
- 1007170
- 1007171
- 0
- 10071701
-
-
- 772281
- 772283
- 772283
- 772284
- 772281
- 772283
- 772283
- 772282
- 772281
- 772282
- 772282
- 0
- 8495105
-
-
- 672837
- 672841
- 672841
- 672841
- 672841
- 672842
- 672841
- 672841
- 672842
- 672841
- 672841
- 672841
- 0
- 8074090
-
-
- 595160
- 595163
- 595162
- 595163
- 595161
- 595162
- 595162
- 595163
- 595162
- 595162
- 595162
- 595162
- 595162
- 0
- 7737106
-
-
- 581536
- 581540
- 581539
- 581539
- 581539
- 581539
- 581539
- 581538
- 581540
- 581539
- 581538
- 581539
- 581539
- 581540
- 0
- 8141544
-
-
- 578439
- 578441
- 578442
- 578441
- 578442
- 578441
- 578442
- 578444
- 578441
- 578442
- 578441
- 578440
- 578441
- 578441
- 578442
- 0
- 8676620
-
-
- 527784
- 527783
- 527785
- 527784
- 527784
- 527783
- 527782
- 527784
- 527782
- 527782
- 527784
- 527783
- 527783
- 527783
- 527783
- 527783
- 0
- 8444532
-
-
- 468012
- 468009
- 468009
- 468010
- 468011
- 468010
- 468011
- 468009
- 468009
- 468010
- 468011
- 468012
- 468009
- 468011
- 468011
- 468011
- 468012
- 0
- 7956177
-
-
- 439238
- 439222
- 439228
- 439225
- 439226
- 439228
- 439226
- 439219
- 439231
- 439213
- 439226
- 439215
- 439215
- 439222
- 439224
- 439217
- 439226
- 439230
- 0
- 7906031
-
-
- 392577
- 392658
- 392677
- 392625
- 392645
- 392611
- 392643
- 392617
- 392519
- 392507
- 392525
- 392515
- 392513
- 392488
- 392567
- 392567
- 392175
- 392148
- 392153
- 0
- 7457730
-
-
- 393189
- 393145
- 393365
- 393284
- 393215
- 393191
- 393247
- 393229
- 392255
- 392239
- 392268
- 392259
- 392312
- 392395
- 392318
- 392431
- 389204
- 389161
- 389146
- 389191
- 0
- 7841044
-
-
- 333867
- 333818
- 333796
- 333998
- 333786
- 333970
- 333966
- 333946
- 331691
- 331644
- 331574
- 331570
- 331815
- 331757
- 331873
- 331902
- 321858
- 321819
- 321778
- 321915
- 322036
- 0
- 6934379
-
-
- 336076
- 336030
- 335863
- 335861
- 335954
- 336069
- 335963
- 335891
- 336178
- 335697
- 335574
- 335581
- 335586
- 336068
- 336138
- 336049
- 330987
- 330865
- 331086
- 330937
- 331150
- 330937
- 0
- 7360540
-
-
- 317093
- 317207
- 317153
- 317177
- 317207
- 317164
- 317198
- 317132
- 317445
- 317166
- 317044
- 317000
- 317012
- 317587
- 317522
- 317568
- 315579
- 315563
- 315657
- 315582
- 315453
- 315445
- 315774
- 0
- 7284728
-
-
- 312519
- 312750
- 312612
- 312671
- 312685
- 312707
- 312543
- 312680
- 313250
- 312566
- 312775
- 312827
- 312652
- 313141
- 313261
- 313270
- 312883
- 312649
- 312529
- 312615
- 312755
- 312833
- 312673
- 312728
- 0
- 7506574
-
-
- 149325
- 149327
- 149325
- 149325
- 149325
- 149327
- 149325
- 149324
- 149326
- 149325
- 149326
- 149326
- 149326
- 149325
- 149325
- 149325
- 149325
- 149325
- 149325
- 149326
- 149325
- 149326
- 149325
- 149325
- 3583809
- 3583809
-
-
- 219612
- 219612
- 219612
- 219612
- 219612
- 219612
- 219613
- 219612
- 219612
- 219614
- 219612
- 219611
- 219613
- 219614
- 219612
- 219612
- 219613
- 219613
- 219611
- 219612
- 219611
- 219612
- 219612
- 219613
- 5270694
- 5270694
-
-
- 17976591
- 0
- 17976591
-
-
- 17093434
- 17094750
- 0
- 34188184
-
-
- 16126005
- 16127191
- 16875254
- 0
- 49128450
-
-
- 15412620
- 15413887
- 15366643
- 15366578
- 0
- 61559728
-
-
- 16308721
- 16310021
- 16318960
- 16318983
- 16426938
- 0
- 81683623
-
-
- 15193884
- 15195117
- 15113407
- 15121476
- 15104027
- 15104373
- 0
- 90832284
-
-
- 15794728
- 15792858
- 15790710
- 15798703
- 15746011
- 15746393
- 15839713
- 0
- 110509116
-
-
- 14538979
- 14540011
- 14540067
- 14543590
- 14523331
- 14523800
- 14541196
- 14543759
- 0
- 116294733
-
-
- 14597172
- 14598178
- 14594621
- 14598190
- 14558148
- 14558565
- 14603981
- 14614317
- 18013252
- 0
- 134736424
-
-
- 14529346
- 14530425
- 14525274
- 14530395
- 14501600
- 14501959
- 14539379
- 14546701
- 16764576
- 16764953
- 0
- 149734608
-
-
- 14552313
- 14545774
- 14543859
- 14545590
- 14521699
- 14522178
- 14548350
- 14554882
- 15834293
- 15834734
- 16861946
- 0
- 164865618
-
-
- 14544735
- 14545749
- 14545348
- 14545729
- 14531175
- 14531582
- 14545221
- 14552316
- 15709806
- 15710183
- 15613298
- 15613336
- 0
- 178988478
-
-
- 14631943
- 14629081
- 14626428
- 14629173
- 14592751
- 14593171
- 14633428
- 14642988
- 16103014
- 16103498
- 16121344
- 16121522
- 16592935
- 0
- 198021276
-
-
- 14663977
- 14657392
- 14653868
- 14657385
- 14618995
- 14619260
- 14663280
- 14669006
- 14932649
- 14933133
- 14914884
- 14922839
- 14912239
- 14912618
- 0
- 206731525
-
-
- 14574685
- 14571820
- 14569180
- 14571882
- 14535038
- 14535448
- 14576273
- 14588007
- 15847051
- 15847907
- 15842926
- 15845292
- 15844741
- 15845144
- 15858663
- 0
- 227454057
-
-
- 14565742
- 14566794
- 14563059
- 14566698
- 14539138
- 14539550
- 14572545
- 14582815
- 14708684
- 14709444
- 14704986
- 14705363
- 14739299
- 14739959
- 14685047
- 14684929
- 0
- 234174052
-
-
- 14578846
- 14579881
- 14577981
- 14579886
- 14572709
- 14573049
- 14582536
- 14584350
- 15007742
- 15008395
- 15007420
- 15007658
- 15014167
- 15014785
- 15005244
- 15005419
- 18174844
- 0
- 254874912
-
-
- 14520800
- 14521760
- 14516500
- 14519179
- 14488245
- 14488682
- 14533956
- 14545682
- 14854184
- 14854859
- 14853940
- 14854226
- 14853922
- 14854597
- 14853928
- 14854269
- 16695502
- 16695771
- 0
- 268360002
-
-
- 14767102
- 14756811
- 14754774
- 14756725
- 14720166
- 14720526
- 14759446
- 14768164
- 15010901
- 15011570
- 15010636
- 15010954
- 15010667
- 15011279
- 15010747
- 15011090
- 16740850
- 16741140
- 16740556
- 0
- 288314104
-
-
- 14503694
- 14504695
- 14504309
- 14504656
- 14481517
- 14481930
- 14504225
- 14511441
- 14881230
- 14881959
- 14880910
- 14881278
- 14881048
- 14881629
- 14881078
- 14881274
- 15921487
- 15921957
- 15772241
- 15772141
- 0
- 298434699
-
-
- 14585345
- 14586417
- 14584462
- 14586324
- 14561834
- 14562194
- 14589003
- 14593127
- 14651792
- 14652414
- 14651588
- 14651811
- 14651560
- 14652081
- 14651657
- 14651849
- 15956242
- 15956591
- 15917381
- 15917342
- 16692459
- 0
- 314303473
-
-
- 14567398
- 14564632
- 14561858
- 14564593
- 14537808
- 14538183
- 14568901
- 14571570
- 14824939
- 14825595
- 14824563
- 14824936
- 14824664
- 14825180
- 14824622
- 14824869
- 15000394
- 15000816
- 15132415
- 15132390
- 14957113
- 14957467
- 0
- 325254906
-
-
- 14533130
- 14526680
- 14523900
- 14526694
- 14473827
- 14474177
- 14530917
- 14540399
- 14689348
- 14690045
- 14689080
- 14689352
- 14689191
- 14689822
- 14689153
- 14689383
- 15149225
- 15149721
- 15149099
- 15149020
- 15149087
- 15149374
- 15723066
- 0
- 340263690
-
-
- 14520191
- 14521316
- 14520064
- 14521273
- 14508861
- 14509277
- 14522439
- 14523376
- 14971139
- 14971788
- 14970834
- 14971145
- 14970850
- 14971356
- 14970773
- 14971212
- 14302288
- 14302674
- 14292318
- 14292258
- 14327757
- 14328109
- 14203917
- 14204596
- 0
- 350169811
-
-
- 12082070
- 0
- 12082070
-
-
- 11860565
- 11861524
- 0
- 23722089
-
-
- 10937185
- 11666176
- 11377885
- 0
- 33981246
-
-
- 10711169
- 11044642
- 10712186
- 10711772
- 0
- 43179769
-
-
- 10681736
- 10803241
- 10697774
- 10697365
- 10786731
- 0
- 53666847
-
-
- 10202899
- 10453899
- 10236078
- 10235641
- 10203405
- 10435466
- 0
- 61767388
-
-
- 10057432
- 10126310
- 10062880
- 10062441
- 10056560
- 10117801
- 10136814
- 0
- 70620238
-
-
- 9534620
- 9563972
- 9529566
- 9529136
- 9534974
- 9559121
- 9532504
- 9532098
- 0
- 76315991
-
-
- 9588196
- 9644812
- 9569541
- 9569144
- 9588269
- 9635446
- 9587520
- 9587124
- 12171038
- 0
- 88941090
-
-
- 9494406
- 9569092
- 9483166
- 9482828
- 9494096
- 9549855
- 9493566
- 9493228
- 11870461
- 11870751
- 0
- 99801449
-
-
- 9547513
- 9618639
- 9531079
- 9530708
- 9544013
- 9582528
- 9546188
- 9545855
- 10981480
- 11695200
- 11417956
- 0
- 110541159
-
-
- 9480940
- 9534711
- 9471781
- 9471472
- 9481875
- 9525995
- 9478339
- 9478029
- 10711265
- 11114755
- 10711627
- 10711294
- 0
- 119172083
-
-
- 9546022
- 9587726
- 9539512
- 9539112
- 9546798
- 9572802
- 9547437
- 9547014
- 10700918
- 10778357
- 10711682
- 10711355
- 10766560
- 0
- 130095295
-
-
- 9529110
- 9587899
- 9523029
- 9522600
- 9529393
- 9562307
- 9531767
- 9531364
- 10124795
- 10538492
- 10167869
- 10167494
- 10101866
- 10500389
- 0
- 137918374
-
-
- 9566449
- 9604833
- 9559288
- 9558898
- 9567098
- 9599387
- 9566496
- 9566147
- 10075047
- 10164135
- 10082703
- 10082326
- 10075244
- 10155140
- 10178314
- 0
- 147401505
-
-
- 9508977
- 9585956
- 9501428
- 9501014
- 9508465
- 9556360
- 9512315
- 9511916
- 9534416
- 9549972
- 9531251
- 9530849
- 9535299
- 9547690
- 9533669
- 9533330
- 0
- 152482907
-
-
- 9456577
- 9518572
- 9448329
- 9447904
- 9456755
- 9492156
- 9456619
- 9456290
- 9469695
- 9504090
- 9467165
- 9466779
- 9469736
- 9490753
- 9470460
- 9470100
- 12081737
- 0
- 163623717
-
-
- 9528572
- 9578324
- 9512159
- 9511743
- 9526173
- 9569951
- 9534866
- 9534526
- 9544758
- 9593215
- 9539533
- 9539119
- 9545198
- 9585695
- 9543578
- 9543186
- 11927396
- 11927804
- 0
- 176585796
-
-
- 9477447
- 9564597
- 9452396
- 9451981
- 9473225
- 9533594
- 9478730
- 9478355
- 9491282
- 9542542
- 9469974
- 9469570
- 9488649
- 9533937
- 9493941
- 9493595
- 10869069
- 11610326
- 11333158
- 0
- 185706368
-
-
- 9513336
- 9581580
- 9502256
- 9501888
- 9514403
- 9561923
- 9510586
- 9510218
- 9577756
- 9601845
- 9576720
- 9576333
- 9576562
- 9591627
- 9575875
- 9575454
- 10774344
- 11131500
- 10795173
- 10794817
- 0
- 196344196
-
-
- 9489784
- 9553505
- 9480407
- 9480031
- 9487187
- 9517609
- 9490215
- 9489795
- 9480100
- 9512956
- 9469789
- 9469408
- 9478224
- 9507407
- 9480884
- 9480522
- 10558463
- 10781768
- 10586536
- 10586157
- 10751665
- 0
- 205132412
-
-
- 9529280
- 9596479
- 9526225
- 9525841
- 9530068
- 9560604
- 9526967
- 9526692
- 9535973
- 9579641
- 9521811
- 9521452
- 9533157
- 9572320
- 9537636
- 9537265
- 10282870
- 10460861
- 10307364
- 10307036
- 10284193
- 10447335
- 0
- 214751070
-
-
- 9474195
- 9526351
- 9466045
- 9465650
- 9474273
- 9509635
- 9475163
- 9474803
- 9527687
- 9582242
- 9516774
- 9516407
- 9526734
- 9556254
- 9528842
- 9528456
- 9971596
- 10094615
- 9984885
- 9984498
- 9969546
- 10080306
- 10113352
- 0
- 222348309
-
-
- 9570183
- 9596856
- 9566396
- 9565955
- 9570347
- 9592890
- 9571708
- 9571344
- 9568931
- 9609557
- 9562498
- 9562127
- 9567335
- 9602518
- 9566096
- 9565736
- 9608409
- 9631716
- 9604886
- 9604505
- 9607807
- 9629640
- 9603907
- 9629626
- 0
- 230130973
-
-
- 903446
- 903762
- 903658
- 903679
- 903658
- 903690
- 903665
- 903667
- 905432
- 905463
- 905415
- 905426
- 905442
- 905442
- 905434
- 905417
- 902746
- 902734
- 902731
- 902719
- 902734
- 902750
- 902746
- 902708
- 2057722
- 21694564
-
-
- 859801
- 967785
- 883645
- 883619
- 860037
- 968025
- 883058
- 883016
- 865337
- 974824
- 882369
- 882341
- 863544
- 972159
- 892721
- 892715
- 857049
- 963725
- 880627
- 880584
- 856853
- 963380
- 854026
- 952345
- 1763851
- 21623585
-
-
- 122500
- 122500
- 122500
- 122500
- 122499
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122500
- 122499
- 122501
- 122500
- 122500
- 122501
- 122501
- 122501
- 122501
- 0
- 2940003
-
-
- 109856
- 109857
- 109857
- 109856
- 109857
- 109856
- 109857
- 109857
- 109856
- 109856
- 109857
- 109858
- 109858
- 109857
- 109856
- 109856
- 109858
- 109857
- 109857
- 109857
- 109856
- 109857
- 109856
- 109857
- 0
- 2636562
-
-
- 2443697
- 1
- 11
- 19
- 34
- 4
- 11
- 27
- 738
- 715
- 708
- 710
- 716
- 722
- 663
- 680
- 818
- 816
- 798
- 793
- 749
- 737
- 681
- 713
- 0
- 2455561
-
-
- 19899718
- 0
- 19899718
-
-
- 11323121
- 8390566
- 0
- 19713687
-
-
- 3505442
- 3505599
- 12137521
- 0
- 19148562
-
-
- 3973366
- 3973543
- 5643661
- 5644098
- 0
- 19234668
-
-
- 3605358
- 3605432
- 5184535
- 5184801
- 1514959
- 0
- 19095085
-
-
- 3062204
- 3061638
- 2657329
- 2657997
- 3694149
- 3693569
- 0
- 18826886
-
-
- 1413952
- 1413322
- 5634774
- 5634907
- 807079
- 806823
- 2780299
- 0
- 18491156
-
-
- 2266504
- 2264023
- 2150464
- 2152501
- 2234184
- 2235885
- 2045159
- 2042094
- 0
- 17390814
-
-
- 378978
- 493897
- 540956
- 307717
- 559266
- 435771
- 289002
- 524768
- 904
- 0
- 3531259
-
-
- 315240
- 314639
- 343225
- 343430
- 330617
- 273430
- 114457
- 400594
- 199708
- 398954
- 0
- 3034294
-
-
- 398649
- 243725
- 313197
- 341559
- 400879
- 485957
- 256149
- 312463
- 79929
- 79959
- 61
- 0
- 2912527
-
-
- 200097
- 314280
- 484541
- 400413
- 187776
- 244998
- 244859
- 330577
- 159931
- 122121
- 159973
- 199451
- 0
- 3049017
-
-
- 104
- 145
- 209
- 169
- 206
- 120
- 166
- 188
- 798353
- 639101
- 1237960
- 840661
- 439274
- 0
- 3956656
-
-
- 80
- 111
- 119
- 149
- 169
- 117
- 126
- 139
- 574829
- 803988
- 370549
- 846318
- 608269
- 608119
- 0
- 3813082
-
-
- 8
- 20
- 34
- 65
- 84
- 38
- 60
- 95
- 482715
- 607538
- 482392
- 667855
- 409336
- 630426
- 408163
- 0
- 3688829
-
-
- 117285
- 117670
- 117122
- 116813
- 117713
- 117774
- 117459
- 117328
- 303833
- 326784
- 277325
- 373516
- 263215
- 390871
- 446935
- 301501
- 0
- 3623144
-
-
- 341558
- 231787
- 347677
- 218478
- 303719
- 154437
- 229631
- 216461
- 123537
- 103366
- 55161
- 90025
- 84691
- 68924
- 53786
- 190767
- 986
- 0
- 2814991
-
-
- 200069
- 264598
- 170182
- 138554
- 102824
- 175867
- 284187
- 164345
- 233732
- 178177
- 140189
- 153958
- 123252
- 227322
- 194095
- 54981
- 1079
- 1026
- 0
- 2808437
-
-
- 321115
- 371397
- 225899
- 354262
- 361476
- 350114
- 291933
- 196999
- 22397
- 25153
- 102182
- 21372
- 70582
- 29948
- 18969
- 57177
- 477
- 391
- 916
- 0
- 2822759
-
-
- 393436
- 309283
- 168529
- 224983
- 196844
- 140974
- 197196
- 84830
- 111946
- 111914
- 112325
- 112014
- 168007
- 111972
- 112201
- 252562
- 49
- 41
- 37
- 44
- 0
- 2809187
-
-
- 183153
- 263091
- 196238
- 56135
- 252253
- 112377
- 168624
- 252596
- 195948
- 43703
- 140073
- 223721
- 251924
- 169611
- 112360
- 168176
- 41
- 14
- 29
- 41
- 41
- 0
- 2790149
-
-
- 84315
- 168428
- 56084
- 280784
- 160642
- 195812
- 224182
- 112335
- 223416
- 279221
- 223306
- 195550
- 83826
- 83644
- 153478
- 251574
- 31
- 17
- 26
- 27
- 31
- 22
- 0
- 2776751
-
-
- 251094
- 111612
- 111946
- 250878
- 270360
- 83918
- 167667
- 251032
- 201670
- 195227
- 167446
- 194880
- 194852
- 83768
- 160169
- 83658
- 141
- 133
- 122
- 117
- 136
- 115
- 104
- 0
- 2781045
-
-
- 132034
- 131676
- 132311
- 131443
- 132250
- 131733
- 131193
- 131281
- 122650
- 123113
- 123745
- 123264
- 123158
- 122764
- 123050
- 123616
- 122054
- 122876
- 122080
- 121904
- 122223
- 122088
- 121899
- 122670
- 0
- 3017075
-
-
- 19645977
- 0
- 19645977
-
-
- 4310217
- 15293675
- 0
- 19603892
-
-
- 9402863
- 9226207
- 437594
- 0
- 19066664
-
-
- 3386951
- 3201931
- 6304744
- 6305238
- 0
- 19198864
-
-
- 4092852
- 3899527
- 2520768
- 2175848
- 5948549
- 0
- 18637544
-
-
- 2597841
- 2443137
- 3331024
- 2708000
- 4093981
- 3080494
- 0
- 18254477
-
-
- 1216614
- 2258952
- 1291063
- 1114575
- 5532606
- 5466345
- 1405693
- 0
- 18285848
-
-
- 2086492
- 2244683
- 2112130
- 2067114
- 2081711
- 2090180
- 2168032
- 2534478
- 0
- 17384820
-
-
- 634132
- 601192
- 480382
- 657643
- 592079
- 740174
- 465043
- 642726
- 3226
- 0
- 4816597
-
-
- 142972
- 387723
- 457567
- 302196
- 314638
- 457645
- 371900
- 428999
- 691
- 362
- 0
- 2864693
-
-
- 355770
- 383778
- 369646
- 256341
- 327558
- 242178
- 398681
- 483955
- 176
- 201
- 67
- 0
- 2818351
-
-
- 457238
- 142885
- 416308
- 318737
- 371610
- 228382
- 429095
- 502040
- 160
- 115
- 191
- 108
- 0
- 2866869
-
-
- 155562
- 155271
- 154524
- 155620
- 155737
- 155945
- 156319
- 155596
- 526245
- 524881
- 495452
- 497374
- 586585
- 0
- 3875111
-
-
- 862
- 739
- 902
- 876
- 922
- 881
- 877
- 945
- 798225
- 545250
- 758729
- 466001
- 638255
- 660193
- 0
- 3873657
-
-
- 198289
- 203179
- 199945
- 199124
- 201799
- 199812
- 199839
- 199732
- 314842
- 291197
- 294608
- 286440
- 375388
- 316600
- 354856
- 0
- 3835650
-
-
- 104577
- 489911
- 466186
- 366690
- 252721
- 460887
- 253823
- 113506
- 120249
- 46275
- 159071
- 83449
- 177618
- 120903
- 191314
- 263287
- 0
- 3670467
-
-
- 234559
- 118245
- 219127
- 295109
- 248960
- 181934
- 297815
- 322059
- 163004
- 174212
- 26569
- 77433
- 133062
- 232843
- 33886
- 82456
- 4914
- 0
- 2846187
-
-
- 271262
- 355312
- 50921
- 148825
- 245230
- 182256
- 187273
- 255451
- 185514
- 44729
- 112757
- 98411
- 207969
- 185668
- 172032
- 109135
- 2423
- 2380
- 0
- 2817548
-
-
- 261804
- 234937
- 211116
- 198275
- 153636
- 353607
- 368351
- 369817
- 117702
- 41853
- 75374
- 125194
- 87239
- 58610
- 63622
- 96700
- 1021
- 966
- 985
- 0
- 2820809
-
-
- 251976
- 118001
- 84641
- 140476
- 77669
- 274047
- 318570
- 170363
- 252676
- 140874
- 189186
- 121034
- 161358
- 165381
- 141826
- 205937
- 118
- 77
- 70
- 94
- 0
- 2814374
-
-
- 84213
- 196158
- 196680
- 112159
- 224637
- 252342
- 140314
- 84179
- 223626
- 196078
- 111882
- 238331
- 252259
- 195491
- 83883
- 195126
- 52
- 26
- 35
- 44
- 41
- 0
- 2787556
-
-
- 31503
- 252623
- 196406
- 168591
- 140544
- 168154
- 280249
- 168483
- 195559
- 55718
- 139401
- 251481
- 222605
- 111214
- 139519
- 251258
- 46
- 26
- 31
- 39
- 39
- 41
- 0
- 2773530
-
-
- 139311
- 167336
- 278426
- 55951
- 139626
- 250691
- 223121
- 83809
- 194537
- 278533
- 139061
- 223216
- 194994
- 111343
- 186244
- 111364
- 142
- 126
- 121
- 122
- 124
- 125
- 124
- 0
- 2778447
-
-
- 127539
- 128004
- 127243
- 128231
- 128122
- 127956
- 128394
- 128093
- 121225
- 120770
- 120549
- 120785
- 120461
- 120591
- 121214
- 120733
- 120387
- 121153
- 121255
- 120737
- 120859
- 121071
- 121031
- 121163
- 0
- 2957566
-
-
+*** TEST VERSION: 6.0.0.90c8934179f2ba4c042caa95b3473d37835bed80
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_SMP
+*** TEST TOOLS: 13.2.0 20230727 (RTEMS 6, RSB d3d738c35a71ca05f675b188539225099401ac79, Newlib a021448)
+*** BEGIN OF JSON DATA ***
+[
+ {
+ "lock-type": "Ticket Lock",
+ "lock-object": "global",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [1385097],
+ "global-counter": 0,
+ "sum-of-local-counter": 1385097
+ }, {
+ "counter": [997876, 997974],
+ "global-counter": 0,
+ "sum-of-local-counter": 1995850
+ }, {
+ "counter": [998024, 998123, 998123],
+ "global-counter": 0,
+ "sum-of-local-counter": 2994270
+ }, {
+ "counter": [997988, 998086, 998086, 998086],
+ "global-counter": 0,
+ "sum-of-local-counter": 3992246
+ }
+ ]
+ }, {
+ "lock-type": "MCS Lock",
+ "lock-object": "global",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [1512045],
+ "global-counter": 0,
+ "sum-of-local-counter": 1512045
+ }, {
+ "counter": [997877, 997878],
+ "global-counter": 0,
+ "sum-of-local-counter": 1995755
+ }, {
+ "counter": [998023, 998122, 998122],
+ "global-counter": 0,
+ "sum-of-local-counter": 2994267
+ }, {
+ "counter": [997987, 998086, 998086, 998086],
+ "global-counter": 0,
+ "sum-of-local-counter": 3992245
+ }
+ ]
+ }, {
+ "lock-type": "Ticket Lock",
+ "lock-object": "global",
+ "section-type": "global counter",
+ "results": [
+ {
+ "counter": [997921, 997945, 997945, 997945],
+ "global-counter": 3991756,
+ "sum-of-local-counter": 3991756
+ }
+ ]
+ }, {
+ "lock-type": "MCS Lock",
+ "lock-object": "global",
+ "section-type": "global counter",
+ "results": [
+ {
+ "counter": [527090, 527096, 527096, 527096],
+ "global-counter": 2108378,
+ "sum-of-local-counter": 2108378
+ }
+ ]
+ }, {
+ "lock-type": "Ticket Lock",
+ "lock-object": "local",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [1385769],
+ "global-counter": 0,
+ "sum-of-local-counter": 1385769
+ }, {
+ "counter": [1385995, 1387328],
+ "global-counter": 0,
+ "sum-of-local-counter": 2773323
+ }, {
+ "counter": [1386191, 1387525, 1387526],
+ "global-counter": 0,
+ "sum-of-local-counter": 4161242
+ }, {
+ "counter": [1386136, 1387468, 1387470, 1387407],
+ "global-counter": 0,
+ "sum-of-local-counter": 5548481
+ }
+ ]
+ }, {
+ "lock-type": "MCS Lock",
+ "lock-object": "local",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [1512021],
+ "global-counter": 0,
+ "sum-of-local-counter": 1512021
+ }, {
+ "counter": [1511993, 1513445],
+ "global-counter": 0,
+ "sum-of-local-counter": 3025438
+ }, {
+ "counter": [1512208, 1513656, 1513656],
+ "global-counter": 0,
+ "sum-of-local-counter": 4539520
+ }, {
+ "counter": [1512149, 1513595, 1513595, 1513533],
+ "global-counter": 0,
+ "sum-of-local-counter": 6052872
+ }
+ ]
+ }, {
+ "lock-type": "Ticket Lock",
+ "lock-object": "local",
+ "section-type": "global counter",
+ "results": [
+ {
+ "counter": [1160403, 1161527, 1161527, 1161469],
+ "global-counter": 3727827,
+ "sum-of-local-counter": 4644926
+ }
+ ]
+ }, {
+ "lock-type": "MCS Lock",
+ "lock-object": "local",
+ "section-type": "global counter",
+ "results": [
+ {
+ "counter": [1247164, 1248373, 1248373, 1248313],
+ "global-counter": 3876384,
+ "sum-of-local-counter": 4992223
+ }
+ ]
+ }, {
+ "lock-type": "Ticket Lock",
+ "lock-object": "global",
+ "section-type": "busy loop",
+ "results": [
+ {
+ "counter": [39932, 39932, 39932, 39932],
+ "global-counter": 0,
+ "sum-of-local-counter": 159728
+ }
+ ]
+ }, {
+ "lock-type": "MCS Lock",
+ "lock-object": "global",
+ "section-type": "busy loop",
+ "results": [
+ {
+ "counter": [39934, 39935, 39934, 39934],
+ "global-counter": 0,
+ "sum-of-local-counter": 159737
+ }
+ ]
+ }, {
+ "lock-type": "Sequence Lock",
+ "lock-object": "global",
+ "section-type": "two global counter",
+ "results": [
+ {
+ "counter": [1847772, 666526, 666526, 666488],
+ "global-counter": 0,
+ "sum-of-local-counter": 3847312
+ }
+ ]
+ }, {
+ "lock-type": "TAS Lock",
+ "lock-object": "global",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [2934600],
+ "global-counter": 0,
+ "sum-of-local-counter": 2934600
+ }, {
+ "counter": [2217444, 2219107],
+ "global-counter": 0,
+ "sum-of-local-counter": 4436551
+ }, {
+ "counter": [1833240, 1836467, 1835261],
+ "global-counter": 0,
+ "sum-of-local-counter": 5504968
+ }, {
+ "counter": [1652247, 1652937, 1653163, 1652725],
+ "global-counter": 0,
+ "sum-of-local-counter": 6611072
+ }
+ ]
+ }, {
+ "lock-type": "TTAS Lock",
+ "lock-object": "global",
+ "section-type": "local counter",
+ "results": [
+ {
+ "counter": [2935135],
+ "global-counter": 0,
+ "sum-of-local-counter": 2935135
+ }, {
+ "counter": [1732426, 1758193],
+ "global-counter": 0,
+ "sum-of-local-counter": 3490619
+ }, {
+ "counter": [1202763, 1204087, 1203894],
+ "global-counter": 0,
+ "sum-of-local-counter": 3610744
+ }, {
+ "counter": [845721, 846759, 848543, 838946],
+ "global-counter": 0,
+ "sum-of-local-counter": 3379969
+ }
+ ]
+ }
+]
+*** END OF JSON DATA ***
+
*** END OF TEST SMPLOCK 1 ***
+
+cpu 0 in error mode (tt = 0x80)
+ 1550147550 000091c0: 91d02000 ta 0x0
diff --git a/testsuites/smptests/smplock01/smplock01fair.py b/testsuites/smptests/smplock01/smplock01fair.py
index 25dd7710f9..a3851ad4c6 100755
--- a/testsuites/smptests/smplock01/smplock01fair.py
+++ b/testsuites/smptests/smplock01/smplock01fair.py
@@ -1,9 +1,6 @@
-#!/usr/bin/env python
-
# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2016 embedded brains GmbH & Co. KG
+# Copyright (C) 2016, 2024 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -25,54 +22,50 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
-import re
-import libxml2
+import json
import math
+import re
import statistics
-from libxml2 import xmlNode
-import matplotlib.pyplot as plt
-data = open('smplock01.scn').read()
-data = re.sub(r'\*\*\*.*\*\*\*', '', data)
-doc = libxml2.parseDoc(data)
-ctx = doc.xpathNewContext()
+import matplotlib.pyplot as plt # type: ignore
+from matplotlib import ticker # type: ignore
-plt.title('SMP Lock Fairness')
-plt.xlabel('Active Workers')
-plt.ylabel('Normed Coefficient of Variation')
-i = 1
-ticket = []
-mcs = []
-tas = []
-ttas = []
+def _normed_coefficient_of_variation(counter: list[int]) -> float:
+ return (statistics.stdev(counter) / statistics.mean(counter)) / math.sqrt(
+ len(counter))
-def m(n):
- return int(xmlNode.getContent(n))
-def normedCoefficientOfVariation(name, i):
- y = map(m, ctx.xpathEval('/SMPLock01/' + name + '[@activeWorker=' + str(i) + ']/LocalCounter'))
- if len(y) == 0:
- raise
- return (statistics.stdev(y) / statistics.mean(y)) / math.sqrt(len(y))
+def _plot(data: dict) -> None:
+ _, axes = plt.subplots()
+ axes.set_title("SMP Lock Fairness")
+ axes.set_xlabel("Active Workers")
+ axes.set_ylabel("Normed Coefficient of Variation")
+ axes.set_yscale("symlog", linthresh=1e-6)
+ x = list(range(2, len(data[0]["results"]) + 1))
+ axes.xaxis.set_major_locator(ticker.FixedLocator(x))
+ for samples in data:
+ if samples["lock-object"] != "global":
+ continue
+ if samples["section-type"] != "local counter":
+ continue
+ y = [
+ _normed_coefficient_of_variation(results["counter"])
+ for results in samples["results"][1:]
+ ]
+ axes.plot(x, y, label=samples["lock-type"], marker="o")
+ axes.legend(loc="best")
+ plt.savefig("smplock01fair.png")
+ plt.savefig("smplock01fair.pdf")
+ plt.close()
-try:
- while True:
- i = i + 1
- ticket.append(normedCoefficientOfVariation('GlobalTicketLockWithLocalCounter', i))
- mcs.append(normedCoefficientOfVariation('GlobalMCSLockWithLocalCounter', i))
- tas.append(normedCoefficientOfVariation('GlobalTASLockWithLocalCounter', i))
- ttas.append(normedCoefficientOfVariation('GlobalTTASLockWithLocalCounter', i))
-except:
- pass
-x = range(2, len(ticket) + 2)
-plt.xticks(x)
-plt.yscale('symlog', linthreshy = 1e-6)
-plt.plot(x, ticket, label = 'Ticket Lock', marker = 'o')
-plt.plot(x, mcs, label = 'MCS Lock', marker = 'o')
-plt.plot(x, tas, label = 'TAS Lock', marker = 'o')
-plt.plot(x, ttas, label = 'TTAS Lock', marker = 'o')
-plt.legend(loc = 'best')
-plt.show()
+_JSON_DATA = re.compile(
+ r"\*\*\* BEGIN OF JSON DATA \*\*\*(.*)"
+ r"\*\*\* END OF JSON DATA \*\*\*", re.DOTALL)
+
+with open("smplock01.scn", "r", encoding="utf-8") as src:
+ match = _JSON_DATA.search(src.read())
+ data = json.loads(match.group(1))
+
+_plot(data)
diff --git a/testsuites/smptests/smplock01/smplock01perf.py b/testsuites/smptests/smplock01/smplock01perf.py
index d27db9b9fe..09c7fb10b4 100755
--- a/testsuites/smptests/smplock01/smplock01perf.py
+++ b/testsuites/smptests/smplock01/smplock01perf.py
@@ -1,9 +1,6 @@
-#!/usr/bin/env python
-
# SPDX-License-Identifier: BSD-2-Clause
-#
-# Copyright (c) 2016 embedded brains GmbH & Co. KG
+# Copyright (C) 2016, 2024 embedded brains GmbH & Co. KG
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -25,34 +22,39 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
+import json
import re
-import libxml2
-from libxml2 import xmlNode
-import matplotlib.pyplot as plt
-data = open('smplock01.scn').read()
-data = re.sub(r'\*\*\*.*\*\*\*', '', data)
-doc = libxml2.parseDoc(data)
-ctx = doc.xpathNewContext()
+import matplotlib.pyplot as plt # type: ignore
+from matplotlib import ticker # type: ignore
-plt.title('SMP Lock Performance')
-plt.xlabel('Active Workers')
-plt.ylabel('Operation Count')
-y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTicketLockWithLocalCounter/SumOfLocalCounter'))
-x = range(1, len(y) + 1)
-plt.xticks(x)
-plt.plot(x, y, label = 'Ticket Lock', marker = 'o')
+def _plot(data: dict) -> None:
+ _, axes = plt.subplots()
+ axes.set_title("SMP Lock Performance")
+ axes.set_xlabel("Active Workers")
+ axes.set_ylabel("Operation Count")
+ x = list(range(1, len(data[0]["results"]) + 1))
+ axes.xaxis.set_major_locator(ticker.FixedLocator(x))
+ for samples in data:
+ if samples["lock-object"] != "global":
+ continue
+ if samples["section-type"] != "local counter":
+ continue
+ y = [sum(results["counter"]) for results in samples["results"]]
+ axes.plot(x, y, label=samples["lock-type"], marker="o")
+ axes.legend(loc="best")
+ plt.savefig("smplock01perf.png")
+ plt.savefig("smplock01perf.pdf")
+ plt.close()
-y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalMCSLockWithLocalCounter/SumOfLocalCounter'))
-plt.plot(x, y, label = 'MCS Lock', marker = 'o')
-y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTASLockWithLocalCounter/SumOfLocalCounter'))
-plt.plot(x, y, label = 'TAS Lock', marker = 'o')
+_JSON_DATA = re.compile(
+ r"\*\*\* BEGIN OF JSON DATA \*\*\*(.*)"
+ r"\*\*\* END OF JSON DATA \*\*\*", re.DOTALL)
-y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTTASLockWithLocalCounter/SumOfLocalCounter'))
-plt.plot(x, y, label = 'TTAS Lock', marker = 'o')
+with open("smplock01.scn", "r", encoding="utf-8") as src:
+ match = _JSON_DATA.search(src.read())
+ data = json.loads(match.group(1))
-plt.legend(loc = 'best')
-plt.show()
+_plot(data)