This is a very small project to experiment with ray tracing and black holes using (and slightly abusing) Newtonian mechanics.
Newtonian mechanics predicts the existence of black holes. Take the escape velocity formula and apply it to the speed of light. The result is the Schwarzschild radius, which is the same formula one derives if they were to perform to full general relativistic calculation.
where
where
where
This is all fine and dandy so long as
This is not physically realistic, obviously, but the resulting images do look like what one might expect a black hole to be.
These benchmarks used a Ryzen 9 7950x on Debian 12.
Language | Implementation | Time (s) | Version |
---|---|---|---|
C | gcc | 11.396 | gcc (Debian 12.2.0-14) 12.2.0 |
C++ | g++ | 11.840 | g++ (Debian 12.2.0-14) 12.2.0 |
D | gdc | 12.186 | gdc (Debian 12.2.0-14) 12.2.0 |
C | clang | 12.199 | Debian clang version 14.0.6 |
D | ldc | 12.204 | LLVM D Compiler (1.30.0) |
Swift | swiftc | 12.216 | Swift version 5.9 (swift-5.9-RELEASE) |
C++ | clang++ | 12.361 | Debian clang version 14.0.6 |
Fortran | gfortran | 12.633 | GNU Fortran (Debian 12.2.0-14) 12.2.0 |
Rust | rustc | 12.681 | rustc 1.72.0 (5680fa18f 2023-08-23) |
Java | openJDK | 12.910 | openjdk 17.0.8 2023-07-18 |
Python | Pypy | 15.481 | PyPy 7.3.11 with GCC 12.2.0 |
Go | golang | 18.118 | go 1.19.8 |
Pascal | fpc | 18.755 | Free Pascal Compiler 3.2.2 20230330 |
Go | gccgo | 18.932 | gccgo (Debian 12.2.0-14) 12.2.0 |
D | dmd | 35.832 | DMD64 D Compiler v2.107.0 |
C | pcc | 62.625 | Portable C Compiler 1.2.0.DEVEL 20220331 |
C | tcc | 70.031 | tcc version 0.9.27 |
Python | CPython | 1876.293 | Python 3.11.2 |
IDL | GDL | 6677.710 | GNU Data Language, Version 1.0.1 |
I haven't made parellel versions in every language, but here are the benchmarks for those that have been done. Ryzen 9 7950x (16-core) on Debian 12.
Language | Implementation | Time (s) | Version |
---|---|---|---|
C | gcc | 0.665 | gcc (Debian 12.2.0-14) 12.2.0 |
C++ | g++ | 0.666 | g++ (Debian 12.2.0-14) 12.2.0 |
C++ | clang++ | 0.961 | Debian clang version 14.0.6 |
C | clang | 0.971 | Debian clang version 14.0.6 |
Go | golang | 1.334 | go 1.19.8 |
Go | gccgo | 1.684 | gccgo (Debian 12.2.0-14) 12.2.0 |
newtonian_black_holes is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
newtonian_black_holes is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with newtonian_black_holes. If not, see <https://www.gnu.org/licenses/>.