You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -88,6 +100,10 @@ This library is designed to be fast. Many techniques are employed to achieve thi
88
100
89
101
Not all the optimizations I want to implement are done yet, but I will be working on them. However, I can already say that the library is fast enough for most use cases.
90
102
103
+
#### Benchmarks
104
+
105
+
The library contains some micro-benchmarks for internal use in the [develop/benchmarks](./develop/benchmarks/) directory, but they are not comprehensive and are not intended for comparison with other ECS libraries. I don't like cross-library benchmarks, as they are often biased and not representative of real-world performance. However, you can look at benchmarks from independent third-party authors, for example, [these](https://github.com/jeffzi/lua-ecs-benchmark) nice benchmarks by [@jeffzi](https://github.com/jeffzi) that cover most libraries, including `evolved.lua`.
106
+
91
107
### Simplicity
92
108
93
109
I have tried to keep the [API](#cheat-sheet) as simple and intuitive as possible. I also keep the number of functions under control. All the functions are self-explanatory and easy to use. After reading the [Overview](#overview) section, you should be able to use the library without any problems.
@@ -1416,6 +1432,24 @@ evolved.builder()
1416
1432
evolved.process_with(MOVEMENT_SYSTEM, 0.016)
1417
1433
```
1418
1434
1435
+
### Error Handling
1436
+
1437
+
Since systems perform processing in a deferred scope, any errors that occur during processing can leave the library in an inconsistent state. To handle this, the library runs a protected call for each system and catches any errors that occur. By default, the library will collect the error message and the current stack trace and rethrow the error with this information. It is safe to catch errors, but it can be inconvenient to use with a debugger, because debuggers usually break on the rethrow instead of the place where the error happened. To make it easier to debug errors in systems, the library provides a way to set a custom error handler that will be called when an error occurs during system processing. For example, you can set an error handler that breaks into the debugger:
1438
+
1439
+
```lua
1440
+
-- we use Local Lua Debugger in this example
1441
+
localdebugger=require'lldebugger'
1442
+
debugger.start()
1443
+
1444
+
localevolved=require'evolved'
1445
+
evolved.error_handler(function(message)
1446
+
debugger.requestBreak()
1447
+
returndebug.traceback(message)
1448
+
end)
1449
+
```
1450
+
1451
+
This way, when an error occurs during system processing, the error handler will be called, which will break into the debugger, allowing you to inspect the state of the program at the moment of the error. After you continue execution in the debugger, the error will be rethrown with the original message and stack trace.
1452
+
1419
1453
### Garbage Collection
1420
1454
1421
1455
While using the library, some internal data structures can become obsolete and should be cleaned up to free memory. For example, empty chunks that no longer contain entities can be removed. Component storages can also have unused capacity that can be shrunk to save memory. The library provides a function to control this garbage collection process.
@@ -1577,6 +1611,7 @@ process :: system... -> ()
1577
1611
process_with :: system, ... -> ()
1578
1612
1579
1613
debug_mode :: boolean -> ()
1614
+
error_handler :: {string -> string}? -> ()
1580
1615
collect_garbage :: boolean? -> ()
1581
1616
```
1582
1617
@@ -1668,6 +1703,12 @@ builder_mt:destruction_policy :: id -> builder
1668
1703
1669
1704
## Changelog
1670
1705
1706
+
### v1.11.0
1707
+
1708
+
- Slightly improved performance of modifying operations for fragments with [`ON_INSERT`](#evolvedon_insert) and [`ON_REMOVE`](#evolvedon_remove) hooks
1709
+
- Slightly improved performance of queries with [`EXPLICIT`](#evolvedexplicit) fragments
1710
+
- Added the new [`evolved.error_handler`](#evolvederror_handler) function that allows setting a custom error handler for better system processing debugging experience
1711
+
1671
1712
### v1.10.0
1672
1713
1673
1714
- Added the new [`evolved.lookup`](#evolvedlookup) and [`evolved.multi_lookup`](#evolvedmulti_lookup) functions that allow finding ids by their names
@@ -2187,6 +2228,13 @@ function evolved.process_with(system, ...) end
0 commit comments