Skip to content

Commit a8f95c6

Browse files
committed
update README
1 parent d40cd0e commit a8f95c6

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
- [Introduction](#introduction)
3232
- [Performance](#performance)
33+
- [Benchmarks](#benchmarks)
3334
- [Simplicity](#simplicity)
3435
- [Flexibility](#flexibility)
3536
- [Installation](#installation)
@@ -65,6 +66,7 @@
6566
- [Fragment Requirements](#fragment-requirements)
6667
- [Destruction Policies](#destruction-policies)
6768
- [Custom Component Storages](#custom-component-storages)
69+
- [Error Handling](#error-handling)
6870
- [Garbage Collection](#garbage-collection)
6971
- [Cheat Sheet](#cheat-sheet)
7072
- [Aliases](#aliases)
@@ -98,6 +100,10 @@ This library is designed to be fast. Many techniques are employed to achieve thi
98100

99101
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.
100102

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+
101107
### Simplicity
102108

103109
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.
@@ -1426,6 +1432,24 @@ evolved.builder()
14261432
evolved.process_with(MOVEMENT_SYSTEM, 0.016)
14271433
```
14281434

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+
local debugger = require 'lldebugger'
1442+
debugger.start()
1443+
1444+
local evolved = require 'evolved'
1445+
evolved.error_handler(function(message)
1446+
debugger.requestBreak()
1447+
return debug.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+
14291453
### Garbage Collection
14301454

14311455
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.

0 commit comments

Comments
 (0)