Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Slow T0 tests: adaptive-dabs cases split and shortened (full fused case nightly), smaller texture_transfer / fill_layers / make_sculptable inputs, shards balanced by time
islandmeddd407fedd76e
diff --git a/docs/testing-flow.md b/docs/testing-flow.mdindex badd36d0..dcd24459 100644--- a/docs/testing-flow.md+++ b/docs/testing-flow.md@@ -78,6 +78,10 @@ Every tier runs ctest through `tools/test/run.py --build build [-- ctest args]`:each. A listed test may grow to 1.5× its seconds (scaled by budget ÷ 20 on CI), so the list can only shrink. Aslow test should wait on events rather than fixed frames, use a smaller mesh or texture, be split, or be labellednightly.+- **Shards by time**: `tests/shard_times.inc` lists the TEST cases of 0.5 s or more with their PC seconds; the+ shards take them longest first, each to the shard with the least work so far (tests/test_main.cpp). When a test+ gets much faster or slower, re-run `tools/test/shard_times.py /tmp/sf-pc-*-times.tsv` (`--override` your branch's+ times file with `--match` for the tests you changed).- **Where the time goes**: `SF_UI_PROFILE=1` makes a UI test print its slowest script lines with real seconds(`SF_PC_ENV=SF_UI_PROFILE=1 ~/Work/.sf/pc.sh . -R ui_bake`).- **Parallel runs** (`ctest -jN`, N > 1): timing checks get CI's slack (`SF_TIME_LIMIT_SCALE=4`, `timeLimit()` indiff --git a/tests/TestHarness.h b/tests/TestHarness.hindex 83ef07fa..ffcf2759 100644--- a/tests/TestHarness.h+++ b/tests/TestHarness.h@@ -40,18 +40,20 @@ inline Document makeDoc(Mesh m) {return d;}-// `sculptforge_tests --shard K/N` (tests/test_main.cpp) runs the tests whose name hashes (FNV-1a) to K modulo N: every-// test is in exactly one of the N shards, a test stays in its shard when others are added, and the slow tests of one-// file (registered next to each other) don't all land in the same shards, as they did by registration index: CI-// runs every other shard on one machine (ctest -I K,,N), and that machine got all the slow ones.+// `sculptforge_tests --shard K/N` (tests/test_main.cpp) runs shard K of N; every test is in exactly one of the N+// shards (sf::test::inShard). Shards are balanced by time, not by count: the tests in tests/shard_times.inc (the+// slow ones, seconds measured on the PC; tools/test/shard_times.py writes it) go longest first to the shard with the+// least work so far (the time-ordered greedy pass), after every other test is placed by its name's hash (FNV-1a), so+// a quick test stays in its shard when others are added and the slow tests of one file don't land together (CI runs+// every other shard on one machine, ctest -I K,,N; by registration index that machine got all the slow ones).inline std::uint32_t shardHash(const char* name) {std::uint32_t h = 2166136261u;for (const char* c = name; *c; ++c) h = (h ^ std::uint8_t(*c)) * 16777619u;return h ^ (h >> 16); // the low bits of FNV-1a alone follow the last character too closely}-inline bool inShard(const char* name, int shard, int shards) {- return shards <= 1 || shardHash(name) % std::uint32_t(shards) == std::uint32_t(shard);-}+// A shard's expected seconds for each of N shards (tests/test_main.cpp), and inShard from it.+std::vector<double> shardSeconds(int shards);+bool inShard(const char* name, int shard, int shards);// A wall-clock limit for a speed check: the value given on a developer machine, four times that on a CI runner// (CI or GITHUB_ACTIONS set: shared, often loaded virtual machines, where Windows runners have flaked at 1.1x), anddiff --git a/tests/shard_times.inc b/tests/shard_times.incnew file mode 100644index 00000000..98971942--- /dev/null+++ b/tests/shard_times.inc@@ -0,0 +1,115 @@+// The sculptforge_tests cases that take 0.5 s or more: median seconds on the PC (RTX 3060, WSL, ctest -j5+// per slot). Written by tools/test/shard_times.py; tests/test_main.cpp balances the shards with it.+{"qremesh_guide_loop_round_an_eye", 16.74},+{"adaptive_dabs_leave_small_brushes_alone", 15.62},+{"texture_transfer_remesh_and_qremesh_keep_the_texture", 15.08},+{"texture_transfer_carries_material_channels", 14.00},+{"texture_layer_undo_stores_only_what_changed", 13.75},+{"qremesh_guide_loop_across_the_symmetry_plane", 11.66},+{"texture_transfer_auto_uv_of_a_dense_sphere_does_not_fold", 10.74},+{"uv_pack_udim_grid_columns_by_rows", 9.82},+{"mesh_maps_live_rebake_on_a_worker_while_fill_layers_evaluate", 9.55},+{"micro_base_stroke_is_the_plain_brush", 8.59},+{"fill_layer_effect_chain_and_channels", 8.50},+{"adaptive_dabs_match_exact_strokes", 8.18},+{"qremesh_sculpt_target_counts", 7.61},+{"adaptive_dabs_match_exact_strokes_2", 7.53},+{"inbox0106_smooth_keeps_quad_remesh_regular_lion", 7.39},+{"voxel_remesh_open_starter_head_stays_solid", 7.19},+{"texture_transfer_speed_at_4k_on_a_million_triangles", 7.01},+{"discord_reconnects_after_discord_restarts", 7.00},+{"bake_perf_4k_from_1m_triangles", 6.46},+{"adaptive_dabs_fused_batches_match_exact_strokes_2", 6.20},+{"micro_crease_strokes_stay_smooth", 6.15},+{"adaptive_dabs_fused_batches_match_exact_strokes", 6.10},+{"face_symmetric_pairs_mirror", 6.04},+{"face_generation_is_deterministic_with_threads", 5.86},+{"generated_remesh_quad_cleans_an_ai_mesh", 5.80},+{"micro_wavelet_stroke_matches_exact", 5.71},+{"qremesh_adaptive_size_varies_quads", 5.62},+{"qremesh_guide_open_curve_turns_the_flow", 5.38},+{"dyntopo_symmetry_remeshes_both_sides_of_an_asymmetric_mesh", 5.14},+{"adaptive_dabs_catch_up_behind_ends_exact", 5.10},+{"face_shapes_on_subdivision_levels", 5.00},+{"qremesh2_is_deterministic", 4.33},+{"inbox0106_keep_masked_tidies_awkward_masks", 4.33},+{"face_fit_finds_the_landmarks_on_a_known_head", 3.98},+{"sculptable_stages_and_landmarks", 3.96},+{"sculptable_deterministic", 3.87},+{"micro_stroke_end_no_spikes_on_a_rough_surface", 3.73},+{"qremesh2_sculpt_beats_legacy", 3.61},+{"brush_packs_every_brush_leaves_a_clean_mark", 3.15},+{"bake_udim_grid_ten_by_two", 3.11},+{"sculptable_command_head", 2.97},+{"texture_transfer_auto_uv_keeps_the_paint", 2.83},+{"material_recipes_are_data_and_wear_the_model", 2.73},+{"qremesh_keep_groups_follows_borders", 2.68},+{"qremesh_vertexpaint_density", 2.48},+{"surface_cursor_cost_is_rays_not_mesh_passes", 2.42},+{"qremesh_keeps_small_pieces", 2.40},+{"texture_stroke_benchmark", 2.38},+{"sculptable_inside_splats_dont_win", 2.37},+{"face_generate_on_the_template_matches_its_shapes", 2.13},+{"qremesh_guide_command_parts_and_projects", 2.13},+{"qremesh_sphere_is_closed_quads_near_target", 2.12},+{"sculptable_texture_and_levels", 2.04},+{"qremesh2_sphere_has_eight_poles", 1.90},+{"brush_previews", 1.81},+{"micro_brushes_each_change_the_surface_and_stay_closed", 1.79},+{"phone_pairing_and_tokens", 1.71},+{"qremesh_command_reports_symmetry", 1.61},+{"qremesh_thin_hard_edged_parts", 1.60},+{"micro_base_release_dabs_fuse", 1.59},+{"face_export_round_trips_keep_morph_targets_and_names", 1.51},+{"splat_commands", 1.48},+{"qremesh2_hard_edges_and_groups", 1.46},+{"inbox0106_smooth_keeps_quad_remesh_regular_sphere", 1.31},+{"close_holes_big_hole_is_quick", 1.25},+{"qremesh2_command_method_and_report", 1.17},+{"adaptive_dabs_normals_during_the_stroke", 1.17},+{"face_weights_fast_path_is_exact_and_not_undoable", 1.13},+{"environment_builtins_load_and_light", 1.13},+{"texture_memory_readouts_are_safe_while_painting", 1.12},+{"micro_wavelet_symmetry_hidden_layer_undo", 1.12},+{"qremesh2_symmetry_is_exact", 1.10},+{"malformed_material_channels_in_a_project_fail_cleanly", 1.06},+{"texture_dab_is_interactive_at_4k_on_a_million_triangles", 1.04},+{"face_parts_eyes_and_teeth", 1.03},+{"transform_perf_million_triangles", 1.02},+{"qremesh_guide_with_symmetry_loops_both_sides", 1.00},+{"bake_bumpy_sphere_maps", 0.99},+{"paint_layers_dab_cost_on_big_mesh", 0.95},+{"project_all_brings_detail_back", 0.95},+{"radial_sixteen_copies_on_a_dense_mesh_stays_interactive", 0.95},+{"texture_transfer_merge_keeps_both_textures", 0.95},+{"radial_json_caps_counts", 0.93},+{"qremesh_transfers_mask_and_vertexpaint", 0.91},+{"kelvinlet_grab_dense_mesh_timing", 0.90},+{"kelvinlet_deferred_far_field_matches_the_immediate_one", 0.89},+{"material_dab_cost_against_base_colour_dab", 0.89},+{"dyntopo_x_symmetry_makes_mirrored_topology", 0.87},+{"micro_wavelet_stroke_reads_and_masks", 0.87},+{"sculptable_floaters_and_crop", 0.87},+{"coarse_levels_closed_at_each_level_and_light", 0.81},+{"qremesh_symmetry_mirrors_the_topology", 0.80},+{"fill_layer_generators_follow_the_mesh_maps", 0.78},+{"fill_layer_command_undo_and_projects", 0.77},+{"kelvinlet_lattice_proxy_matches_the_exact_field", 0.74},+{"qremesh_command_keeps_original_and_undoes", 0.73},+{"sculptable_fills_open_bottom", 0.71},+{"face_takes_parse_bake_and_export", 0.69},+{"timeline_seek_large_mesh_timing", 0.69},+{"divide_uv_sphere", 0.69},+{"micro_base_stroke_symmetry_hidden_mask", 0.67},+{"parallel_brushes_match_serial", 0.66},+{"qremesh_symmetry_off_origin", 0.66},+{"upload_runs_of_a_big_brush_match_one_thread", 0.58},+{"bake_command", 0.57},+{"bvh_refit_after_big_stroke_finds_everything", 0.57},+{"project_all_respects_mask_and_options", 0.57},+{"micro_dab_marks_only_what_changed", 0.55},+{"texture_transfer_pads_the_new_islands", 0.53},+{"micro_range_widens_for_big_strokes", 0.52},+{"recipe_brushes_sculpt", 0.52},+{"divide_cylinder_triangle_fan_caps", 0.50},+{"micro_recipe_brushes_keep_pattern_and_depth", 0.50},diff --git a/tests/slow_tests.txt b/tests/slow_tests.txtindex c05d6dbd..fbaf7087 100644--- a/tests/slow_tests.txt+++ b/tests/slow_tests.txt@@ -2,11 +2,8 @@# full suite, 2026-11-04). A listed test passes up to 1.5x its seconds here; an unlisted one over 20 s fails the run.# Make it fast (wait on events, a smaller mesh or texture, split it) or label it nightly, then delete its line.# name seconds plan-ui_uv_editor 116 unwrap of the full lion head (35 s in one step): a smaller model for T1, the lion nightly+ui_uv_editor 116 not the unwrap (12 s): the 10x2, 4x3 and Pack-button UDIM shape packs (29+16+13 s, uvPack/xatlas); a decimated lion packs as slowly and misses "largest island limits the scale": make the pack fastinsider_drops 100 tools/drops selftest: profile it; split the network-free checks from the packaging ones-ui_fill_layers 71 now 1024 textures (was 2048): re-measure; Paint Layers bakes Mesh Maps at open (29 s)-ui_texture_transfer 71 transfers on a dense sphere: smaller source mesh-ui_make_sculptable 66 two make-sculptable runs on a 150k capture (19 s + 15 s): a 30k captureui_retopo 63 one wait_idle of 23 s (line 103: QRemesh of the sculpt): a lower targetui_first_sculpt 48 the lesson end to end (225 lines, no single long step): split into two scriptsui_texture_paint 40 profile with SF_UI_PROFILE=1@@ -38,10 +35,12 @@ sculptforge_tests: qremesh_sculpt_target_counts 26 fewer tasculptforge_tests: texture_transfer_auto_uv_of_a_dense_sphere_does_not_fold 24 a less dense spheresculptforge_tests: fill_layer_effect_chain_and_channels 24 re-measure with SF_THREADS (21-24 s)sculptforge_tests: qremesh_guide_loop_across_the_symmetry_plane 22 a coarser mesh (21-22 s)-sculptforge_tests: adaptive_dabs_fused_batches_match_exact_strokes 80 new on main 11-04 (adaptive dabs): fewer or shorter strokes, or nightly-sculptforge_tests: adaptive_dabs_match_exact_strokes 41 new on main 11-04 (adaptive dabs): fewer or shorter strokessculptforge_tests: adaptive_dabs_leave_small_brushes_alone 21 new on main 11-04 (adaptive dabs)# Moved to nightly (TEST(nightly_*)), 11-04: inbox0106_keep_masked_voxel_on_a_real_model (82 s),# uv_unwrap_lion_head_by_sharp_edges (54 s), mesh_maps_live_update_is_faster_than_a_full_bake (30 s),# uv_editor_million_triangles_stay_interactive (29 s), face_weights_timing_on_a_500k_head (20 s),# dyntopo_random_strokes_stay_valid (25 s, stress).+# 11-06 (fix/slow-tests): nightly_adaptive_dabs_fused_batches_match_exact_strokes (35 s: 18-dab strokes, every brush in+# batches of 2 and 6; T0 runs 8-dab strokes, each brush in one size, as two tests). adaptive_dabs_match_exact_strokes+# is split in two (8 s each, full length). ui_texture_transfer (Voxel Remesh at resolution 32), ui_fill_layers (a 20k+# sphere), ui_make_sculptable (a 30k capture): 9-16 s now.diff --git a/tests/test_beta_boost.cpp b/tests/test_beta_boost.cppindex c10b6874..bf20ebfd 100644--- a/tests/test_beta_boost.cpp+++ b/tests/test_beta_boost.cpp@@ -15,6 +15,7 @@#include <chrono>#include <algorithm>#include <cmath>+#include <iterator>#include <tuple>using namespace sf;@@ -106,9 +107,8 @@ Difference compare(const Mesh& start, const Mesh& a, const Mesh& b) {return r;}-} // namespace--TEST(adaptive_dabs_match_exact_strokes) {+// Adaptive strokes against the exact ones, for the brushes that take the adaptive path, from `first` (of six), `count` of them.+void adaptiveMatchesExact(size_t first, size_t count) {const Mesh head = makeBenchHead(3'000'000); // ~1.5M vertices: a 0.6 radius holds well over the thresholdstruct Case {BrushType type;@@ -116,8 +116,10 @@ TEST(adaptive_dabs_match_exact_strokes) {float strength = 0.3f;};// (Inflate, Nudge, Clay Block, alpha brushes and masked regions take the exact path: adaptive_dabs_leave_small_brushes_alone checks it.)- for (const Case c : {Case{BrushType::Clay}, Case{BrushType::Standard}, Case{BrushType::Flatten},- Case{BrushType::Pinch}, Case{BrushType::Crease}, Case{BrushType::Trim}}) {+ const Case cases[] = {Case{BrushType::Clay}, Case{BrushType::Standard}, Case{BrushType::Flatten},+ Case{BrushType::Pinch}, Case{BrushType::Crease}, Case{BrushType::Trim}};+ for (size_t i = first; i < std::min(first + count, std::size(cases)); ++i) {+ const Case c = cases[i];const StrokeResult exact = strokeOn(head, c.type, 0.8f, false, 16, c.alpha, c.mask, c.strength);const StrokeResult fast = strokeOn(head, c.type, 0.8f, true, 16, c.alpha, c.mask, c.strength);const Difference d = compare(head, exact.mesh, fast.mesh);@@ -134,19 +136,24 @@ TEST(adaptive_dabs_match_exact_strokes) {}}-TEST(adaptive_dabs_fused_batches_match_exact_strokes) {- // Batches of 2-6 dabs placed in one pass (Sculptor::beginBatch), each picked on the surface as its batch began.+// Batches of 2-6 dabs placed in one pass (Sculptor::beginBatch), each picked on the surface as its batch began:+// strokes of `dabs` dabs, each brush in batches of 2 and of 6 (`bothSizes`), or in one of them, taking turns; the brushes+// from `first` (of six), `count` of them.+void fusedBatchesMatchExact(int dabs, bool bothSizes, size_t first, size_t count) {const Mesh head = makeBenchHead(3'000'000);- for (BrushType type : {BrushType::Clay, BrushType::Standard, BrushType::Flatten, BrushType::Pinch, BrushType::Crease,- BrushType::SharpCrease})+ const BrushType types[] = {BrushType::Clay, BrushType::Standard, BrushType::Flatten, BrushType::Pinch, BrushType::Crease,+ BrushType::SharpCrease};+ for (size_t i = first; i < std::min(first + count, std::size(types)); ++i) {+ const BrushType type = types[i];+ std::vector<glm::vec3> centres;+ static const bool replay = std::getenv("SF_BOOST_REPLAY") != nullptr;+ if (replay) g_record = ¢res;+ const StrokeResult exact = strokeOn(head, type, 0.8f, false, dabs); // (one exact stroke for both sizes)+ g_record = nullptr;for (int batch : {2, 6}) {- std::vector<glm::vec3> centres;- static const bool replay = std::getenv("SF_BOOST_REPLAY") != nullptr;- if (replay) g_record = ¢res;- const StrokeResult exact = strokeOn(head, type, 0.8f, false, 18);- g_record = nullptr;+ if (!bothSizes && batch != (i % 2 ? 6 : 2)) continue;if (replay) g_replay = ¢res;- const StrokeResult fused = strokeOn(head, type, 0.8f, true, 18, false, false, 0.3f, batch);+ const StrokeResult fused = strokeOn(head, type, 0.8f, true, dabs, false, false, 0.3f, batch);g_replay = nullptr;const Difference d = compare(head, exact.mesh, fused.mesh);std::printf(" %-12s batches of %d: moved %.4f, within %.2g (%.2f%%), normals: mean %.3f, 99.9%% within %.2f deg; %.0f vs %.0f ms\n",@@ -156,8 +163,24 @@ TEST(adaptive_dabs_fused_batches_match_exact_strokes) {CHECK(d.position <= 0.025f * d.moved); // within 2.5% (the centres are picked as the batch began)CHECK(d.meanDeg < 0.5);}+ }}+} // namespace++// Each brush's strokes take 1-3 s (the 3M-triangle head copied and its BVH built per stroke): the cases run as two+// tests of three brushes each, which the shards (tests/shard_times.inc) put on different processes.+// Unbatched: the full 16-dab strokes (with 8 the Trim stroke's few moved vertices make its mean normal turn 0.6 deg).+TEST(adaptive_dabs_match_exact_strokes) { adaptiveMatchesExact(0, 3); }+TEST(adaptive_dabs_match_exact_strokes_2) { adaptiveMatchesExact(3, 3); }+// Fused: strokes of 8 dabs (18 nightly). The stroke's length doesn't change the path a dab takes: the 0.8 radius on+// the 3M-triangle head holds every dab's region over Sculptor::kAdaptiveMinVertices (adaptive_dabs_match_exact_strokes+// checks it), and a batch of 6 still fuses (dabs 0-5, then 6-7). Each brush in one batch size, 2 and 6 taking turns,+// so both sizes and every brush's kernel are covered; nightly runs every brush in both, at full length.+TEST(adaptive_dabs_fused_batches_match_exact_strokes) { fusedBatchesMatchExact(8, false, 0, 3); }+TEST(adaptive_dabs_fused_batches_match_exact_strokes_2) { fusedBatchesMatchExact(8, false, 3, 3); }+TEST(nightly_adaptive_dabs_fused_batches_match_exact_strokes) { fusedBatchesMatchExact(18, true, 0, 6); }+TEST(adaptive_dabs_analytic_normals_match_finite_differences) {// PlaneKernel::offsetAndNormal against the moved surface's normal from offsets a hair apart, on a bumpy patch.for (BrushType type : {BrushType::Standard, BrushType::Clay, BrushType::Flatten, BrushType::Crease, BrushType::Pinch,diff --git a/tests/test_harness.cpp b/tests/test_harness.cppindex f54ce918..8a17ca5f 100644--- a/tests/test_harness.cpp+++ b/tests/test_harness.cpp@@ -2,9 +2,11 @@// SPDX-License-Identifier: GPL-3.0-or-later//// The test runner itself: CI runs sculptforge_tests as several shards at once (--shard K/N), which must-// together run every test exactly once.+// together run every test exactly once, balanced by time (tests/shard_times.inc).#include "TestHarness.h"+#include <algorithm>+#include <numeric>#include <vector>TEST(test_shards_cover_every_test_once) {@@ -28,5 +30,11 @@ TEST(test_shards_cover_every_test_once) {for (int k = 0; k < shards; ++k) n[std::size_t(k)] += inShard(t.name, k, shards) ? 1 : 0;const double share = double(tests.size()) / shards;for (std::size_t c : n) CHECK(double(c) <= share * (shards == 16 ? 2.0 : 1.3));+ // And by time: no shard expects more than 1.2 times the mean.+ const std::vector<double> sec = sf::test::shardSeconds(shards);+ const double mean = std::accumulate(sec.begin(), sec.end(), 0.0) / shards;+ const double most = *std::max_element(sec.begin(), sec.end());+ std::printf(" %d shards: %.1f s expected each, the most %.1f s\n", shards, mean, most);+ CHECK(most <= 1.2 * mean);}}diff --git a/tests/test_main.cpp b/tests/test_main.cppindex 88ec578f..3b99a957 100644--- a/tests/test_main.cpp+++ b/tests/test_main.cpp@@ -10,12 +10,75 @@#include "core/Keychain.h"+#include <algorithm>#include <chrono>#include <cstdio>#include <cstring>#include <exception>+#include <map>+#include <string>+#include <unordered_map>#include <vector>+namespace sf::test {+namespace {++struct ShardTime {+ const char* name;+ double seconds;+};+// The slow tests' seconds (tools/test/shard_times.py). Tests not listed count as kUntimedSeconds.+constexpr ShardTime kShardTimes[] = {+#include "shard_times.inc"+};+constexpr double kUntimedSeconds = 0.1;++struct ShardPlan {+ std::unordered_map<std::string, int> shardOf; // the timed tests' shards (the others: by hash)+ std::vector<double> seconds;+};++const ShardPlan& shardPlan(int shards) {+ static std::map<int, ShardPlan> plans;+ auto [it, fresh] = plans.try_emplace(shards);+ ShardPlan& plan = it->second;+ if (!fresh) return plan;+ plan.seconds.assign(std::size_t(shards), 0.0);+ std::unordered_map<std::string, double> timed;+ for (const ShardTime& t : kShardTimes) timed[t.name] = t.seconds;+ std::vector<std::pair<double, const char*>> slow; // (seconds, name) of the registered timed tests+ for (const TestCase& t : registry()) {+ if (std::strncmp(t.name, "nightly_", 8) == 0) continue; // (no shard runs them)+ if (const auto f = timed.find(t.name); f != timed.end()) {+ slow.emplace_back(f->second, t.name);+ } else {+ plan.seconds[shardHash(t.name) % std::uint32_t(shards)] += kUntimedSeconds;+ }+ }+ std::sort(slow.begin(), slow.end(), [](const auto& a, const auto& b) {+ return a.first != b.first ? a.first > b.first : std::strcmp(a.second, b.second) < 0;+ });+ for (const auto& [sec, name] : slow) {+ const auto least = std::min_element(plan.seconds.begin(), plan.seconds.end());+ *least += sec;+ plan.shardOf[name] = int(least - plan.seconds.begin());+ }+ return plan;+}++} // namespace++std::vector<double> shardSeconds(int shards) { return shardPlan(std::max(shards, 1)).seconds; }++bool inShard(const char* name, int shard, int shards) {+ if (shards <= 1) return true;+ const ShardPlan& plan = shardPlan(shards);+ if (const auto f = plan.shardOf.find(name); f != plan.shardOf.end()) return f->second == shard;+ return shardHash(name) % std::uint32_t(shards) == std::uint32_t(shard);+}++} // namespace sf::test+int main(int argc, char** argv) {using namespace sf::test;sf::keychain::useMemoryForTests(true); // no test reads or writes the user's keychain (AI keys, sign-ins)diff --git a/tests/ui/fill_layers.sfui b/tests/ui/fill_layers.sfuiindex 6b14ef2a..e3ce815c 100644--- a/tests/ui/fill_layers.sfui+++ b/tests/ui/fill_layers.sfui@@ -1,7 +1,10 @@# Fill layers and Material Recipes (Tool > Paint Layers): a recipe laid on a sculpted Part reads its Mesh Maps# (baked in the background), the PBR view shows worn metal, a Fill layer's mask effects change from the panel, and# sculpting re-bakes only the tiles near the stroke (live), so the wear follows the new form.-run new_sphere subdivisions=6+# A 20k-triangle sphere (subdivisions 5; 6 is 82k): a frame after texture_create took 15 s at 82k on the PC. The+# strokes, the recipe's worker-thread Mesh Maps bake (at the 1024 texture's size, the least texture_create makes),+# the live tile re-bake and every check are the same.+run new_sphere subdivisions=5run stroke brush=Crease points="-0.6,0.35,1 0,0.55,1 0.6,0.35,1" radius=0.07 strength=1run stroke brush=Inflate points="-0.35,-0.3,1" radius=0.3 strength=1run stroke brush=Clay points="0.25,-0.5,1 0.55,-0.05,1" radius=0.1 strength=1diff --git a/tests/ui/make_sculptable.sfui b/tests/ui/make_sculptable.sfuiindex 98a44784..82f0a30a 100644--- a/tests/ui/make_sculptable.sfui+++ b/tests/ui/make_sculptable.sfui@@ -1,9 +1,11 @@# Make sculptable (Splats palette): the built-in test head capture -> one click -> a quad Part with face loops and# the capture's colours next to the hidden scan; then the review: the face landmarks as dots, one dragged (its mirror# follows and the loops are rebuilt), Finish. The crop box toggles; F3 finds the action.-run splat_test_capture kind=head count=150000+# 30k surface splats (150k took 19 s + 15 s for the two runs): the same scan -> voxel -> QRemesh -> face-loop path; the+# test head's landmarks and loops come from its shape, which 30k splats still cover densely.+run splat_test_capture kind=head count=30000wait 0.5-expect_value splats > 150000+expect_value splats > 30000expect "Make sculptable/Make sculptable"shot capturediff --git a/tests/ui/texture_transfer.sfui b/tests/ui/texture_transfer.sfuiindex 606b896d..6eec7cb1 100644--- a/tests/ui/texture_transfer.sfui+++ b/tests/ui/texture_transfer.sfui@@ -43,6 +43,10 @@ hold ctrlhover "Keep Texture##remesh"expect_help "projected"hold none+# The Voxel Remesh resolution slider at its least, 32 (default 200: 376k triangles, whose Auto UV and projection took+# 27 s of this script on the PC): the same background remesh, Auto UV of the new surface and texture projection, on a+# few thousand triangles. (The source sphere is 5k triangles already; the remesh's output is what costs.)+drag_item "##voxres" -400 0remember triangles before_remeshclick "Voxel Remesh##geometry.remesh"wait_idle 300diff --git a/tools/test/shard_times.py b/tools/test/shard_times.pynew file mode 100755index 00000000..5837e9b3--- /dev/null+++ b/tools/test/shard_times.py@@ -0,0 +1,54 @@+#!/usr/bin/env python3+# SculptForge - open source digital sculpting+# SPDX-License-Identifier: GPL-3.0-or-later+"""Writes tests/shard_times.inc: the sculptforge_tests cases that take MIN seconds or more, with their median seconds,+which tests/test_main.cpp uses to balance the --shard K/N shards by time (TestHarness.h, inShard).++ tools/test/shard_times.py /tmp/sf-pc-*-times.tsv [--override /tmp/sf-pc-<branch>-times.tsv --match REGEX] [--min 0.5]++Reads the per-test times tools/test/run.py writes (`case:<name>\\t<seconds>\\tpass` rows; ~/Work/.sf/pc.sh copies them+to /tmp/sf-pc-<worktree>-times.tsv). --override: these files' times replace the others' for the cases --match finds+(a branch that changed those tests' length; one run's times of the other tests are noisier than the median). Re-run it when a test gets much faster or slower; a missing or stale line only unbalances the shards.+"""+import argparse+import os+import re+import statistics+import sys+++def read_cases(paths):+ times = {}+ for path in paths:+ try:+ with open(path, encoding="utf-8") as f:+ for line in f:+ parts = line.rstrip("\n").split("\t")+ if len(parts) >= 3 and parts[0].startswith("case:") and parts[2] == "pass":+ times.setdefault(parts[0][5:], []).append(float(parts[1]))+ except (OSError, ValueError) as e:+ print(f"shard_times.py: skipping {path}: {e}", file=sys.stderr)+ return {name: statistics.median(v) for name, v in times.items()}+++def main():+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)+ ap.add_argument("tsv", nargs="+")+ ap.add_argument("--override", action="append", default=[])+ ap.add_argument("--match", default="", help="regex: the cases --override replaces (default: all of its cases)")+ ap.add_argument("--min", type=float, default=0.5, help="seconds a case takes to be listed (default 0.5)")+ root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))+ ap.add_argument("--out", default=os.path.join(root, "tests", "shard_times.inc"))+ a = ap.parse_args()+ times = read_cases(a.tsv)+ times.update({n: t for n, t in read_cases(a.override).items() if re.search(a.match, n)})+ rows = sorted(((s, n) for n, s in times.items() if s >= a.min and not n.startswith("nightly_")), key=lambda r: (-r[0], r[1]))+ with open(a.out, "w", encoding="utf-8") as f:+ f.write(f"// The sculptforge_tests cases that take {a.min:g} s or more: median seconds on the PC (RTX 3060, WSL, ctest -j5\n"+ "// per slot). Written by tools/test/shard_times.py; tests/test_main.cpp balances the shards with it.\n")+ f.writelines(f'{{"{n}", {s:.2f}}},\n' for s, n in rows)+ print(f"shard_times.py: {len(rows)} cases, {sum(s for s, _ in rows):.0f} s -> {a.out}")+++if __name__ == "__main__":+ main()