Skip to content

Instantly share code, notes, and snippets.

@millsp
Last active April 17, 2020 16:59
Show Gist options
  • Save millsp/02097996d2a1e4e7aa2d54b330451ea0 to your computer and use it in GitHub Desktop.
Save millsp/02097996d2a1e4e7aa2d54b330451ea0 to your computer and use it in GitHub Desktop.
512000 Minus Operations in 1.3 seconds
import {Any, Number} from 'ts-toolbelt'
/** 512000 Minus Operations
* 80 * 80 * 80 Operations
* ~ 10 240 000 Iterations
* ~ 1.30sec
* @ 3.80GHz
* [email protected]
*/
type test = NestNestTest<'-20'> // 1.3s
type Test<N extends string> = [ // 80 Ops
Number.Minus<'1', N>,
Number.Minus<'2', N>,
Number.Minus<'3', N>,
Number.Minus<'4', N>,
Number.Minus<'5', N>,
Number.Minus<'6', N>,
Number.Minus<'7', N>,
Number.Minus<'8', N>,
Number.Minus<'9', N>,
Number.Minus<'10', N>,
Number.Minus<'11', N>,
Number.Minus<'12', N>,
Number.Minus<'13', N>,
Number.Minus<'14', N>,
Number.Minus<'15', N>,
Number.Minus<'16', N>,
Number.Minus<'17', N>,
Number.Minus<'18', N>,
Number.Minus<'19', N>,
Number.Minus<'20', N>,
Number.Minus<'21', N>,
Number.Minus<'22', N>,
Number.Minus<'23', N>,
Number.Minus<'24', N>,
Number.Minus<'25', N>,
Number.Minus<'26', N>,
Number.Minus<'27', N>,
Number.Minus<'28', N>,
Number.Minus<'29', N>,
Number.Minus<'30', N>,
Number.Minus<'31', N>,
Number.Minus<'32', N>,
Number.Minus<'33', N>,
Number.Minus<'34', N>,
Number.Minus<'35', N>,
Number.Minus<'36', N>,
Number.Minus<'37', N>,
Number.Minus<'38', N>,
Number.Minus<'39', N>,
Number.Minus<'40', N>,
Number.Minus<'-1', N>,
Number.Minus<'-2', N>,
Number.Minus<'-3', N>,
Number.Minus<'-4', N>,
Number.Minus<'-5', N>,
Number.Minus<'-6', N>,
Number.Minus<'-7', N>,
Number.Minus<'-8', N>,
Number.Minus<'-9', N>,
Number.Minus<'-10', N>,
Number.Minus<'-11', N>,
Number.Minus<'-12', N>,
Number.Minus<'-13', N>,
Number.Minus<'-14', N>,
Number.Minus<'-15', N>,
Number.Minus<'-16', N>,
Number.Minus<'-17', N>,
Number.Minus<'-18', N>,
Number.Minus<'-19', N>,
Number.Minus<'-20', N>,
Number.Minus<'-21', N>,
Number.Minus<'-22', N>,
Number.Minus<'-23', N>,
Number.Minus<'-24', N>,
Number.Minus<'-25', N>,
Number.Minus<'-26', N>,
Number.Minus<'-27', N>,
Number.Minus<'-28', N>,
Number.Minus<'-29', N>,
Number.Minus<'-30', N>,
Number.Minus<'-31', N>,
Number.Minus<'-32', N>,
Number.Minus<'-33', N>,
Number.Minus<'-34', N>,
Number.Minus<'-35', N>,
Number.Minus<'-36', N>,
Number.Minus<'-37', N>,
Number.Minus<'-38', N>,
Number.Minus<'-39', N>,
Number.Minus<'-40', N>,
] & {}
type NestTest<N extends string, Test00 = Test<N>> = { // 6400 Ops
[K in keyof Test00]: Test<Any.Cast<Test00[K], string>>
} & {}
type NestNestTest<N extends string, Test00 = Test<N>> = { // 512000 Ops
[K in keyof Test00]: NestTest<Any.Cast<Test00[K], string>>
} & {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment