GAP:Time
Definition
time is a command that can be typed in the interactive GAP shell after the completion of another command. It outputs the total time, in milliseconds, taken to execute the previous command.
Since GAP often caches results, as well as due to changes in the availability of processor and memory resources, the time taken by a command can vary between different contexts. In general, repeat runs of the same command take less time, as more information is cached. The time taken is usually constant after the second run.
Examples
Time for declarations
Very little computation is happening here, so these execute quickly.
gap> G := SymmetricGroup(100); Sym( [ 1 .. 100 ] ) gap> time; 0 gap> G := SymmetricGroup(1000); Sym( [ 1 .. 1000 ] ) gap> time; 0 gap> G := SymmetricGroup(10000); Sym( [ 1 .. 10000 ] ) gap> time; 3
Time for computations
In this example, NormalSubgroups is called for all groups of order 8 (5 in number). The total time taken was 127 milliseconds on the first run, but 57 milliseconds on the second and third run.
gap> List(AllSmallGroups(8), NormalSubgroups);
[ [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1, f3 ]), Group([ f2 ]), Group([ f2*f3 ]),
Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ],
[ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f1, f3 ]), Group([ f1, f2*f3 ]),
Group([ f1, f2 ]), Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1*f3, f2 ]), Group([ f1*f3, f2*f3 ]), Group([ f3 ]), Group([ f1*f3 ]), Group([ f2*f3 ]), Group([ f1*f2*f3 ]), Group([ f2 ]), Group([ f1*f2 ]), Group([ f1 ]),
Group([ ]) ] ]
gap> time;
127
gap> List(AllSmallGroups(8), NormalSubgroups);
[ [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1, f3 ]), Group([ f2 ]), Group([ f2*f3 ]),
Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ],
[ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f1, f3 ]), Group([ f1, f2*f3 ]),
Group([ f1, f2 ]), Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1*f3, f2 ]), Group([ f1*f3, f2*f3 ]), Group([ f3 ]), Group([ f1*f3 ]), Group([ f2*f3 ]), Group([ f1*f2*f3 ]), Group([ f2 ]), Group([ f1*f2 ]), Group([ f1 ]),
Group([ ]) ] ]
gap> time;
57
gap> List(AllSmallGroups(8), NormalSubgroups);
[ [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1, f3 ]), Group([ f2 ]), Group([ f2*f3 ]),
Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ],
[ <pc group of size 8 with 3 generators>, Group([ f2, f3 ]), Group([ f1*f2*f3, f3 ]), Group([ f1, f3 ]), Group([ f3 ]), Group([ ]) ], [ <pc group of size 8 with 3 generators>, Group([ f1, f3 ]), Group([ f1, f2*f3 ]),
Group([ f1, f2 ]), Group([ f2, f3 ]), Group([ f1*f2, f3 ]), Group([ f1*f3, f2 ]), Group([ f1*f3, f2*f3 ]), Group([ f3 ]), Group([ f1*f3 ]), Group([ f2*f3 ]), Group([ f1*f2*f3 ]), Group([ f2 ]), Group([ f1*f2 ]), Group([ f1 ]),
Group([ ]) ] ]
gap> time;
57