Closed Derfies closed 2 years ago
some profiling comparisons
from
Ran 7 tests in 15.077s
to
Ran 7 tests in 32.400s
from
9 0.011 0.001 10.352 1.150 grp.py:233(Randomize)
to
9 0.018 0.002 27.484 3.054 grp.py:233(Randomize)
from
217 0.001 0.000 5.548 0.026 buildmap.py:41(LoadMap)
to
217 0.002 0.000 17.969 0.083 buildmap.py:896(LoadMap)
from
162 0.001 0.000 3.801 0.023 buildmap.py:105(ReadData)
to
162 0.001 0.000 14.584 0.090 buildmap.py:639(ReadData)
from
217 0.002 0.000 4.079 0.019 buildmap.py:152(Randomize)
to
217 0.003 0.000 8.666 0.040 buildmap.py:189(Randomize)
from
217 0.190 0.001 3.039 0.014 buildmap.py:143(ReadSprites)
to
217 0.195 0.001 4.366 0.020 buildmap.py:614(ReadSprites)
here's the full profile of this branch just for buildmap.py
217 0.002 0.000 17.969 0.083 buildmap.py:896(LoadMap)
217 0.004 0.000 17.962 0.083 buildmap.py:124(__init__)
162 0.001 0.000 14.584 0.090 buildmap.py:639(ReadData)
217 0.534 0.002 11.114 0.051 buildmap.py:595(ReadWalls)
917728 2.197 0.000 10.249 0.000 buildmap.py:421(GetWall)
217 0.003 0.000 8.666 0.040 buildmap.py:189(Randomize)
217 0.023 0.000 8.650 0.040 buildmap.py:202(_Randomize)
217 0.009 0.000 6.388 0.029 buildmap.py:650(WriteData)
217 0.195 0.001 4.366 0.020 buildmap.py:614(ReadSprites)
217 0.292 0.001 3.934 0.018 buildmap.py:608(WriteWalls)
917728 2.679 0.000 3.657 0.000 buildmap.py:61(__init__)
917728 0.594 0.000 3.642 0.000 buildmap.py:602(WriteWall)
273314 0.787 0.000 3.628 0.000 buildmap.py:436(GetSprite)
55 0.000 0.000 3.344 0.061 buildmap.py:846(ReadData)
217 0.085 0.000 2.440 0.011 buildmap.py:576(ReadSectors)
138390 0.410 0.000 2.303 0.000 buildmap.py:406(GetSector)
217 0.091 0.000 1.639 0.008 buildmap.py:633(WriteSprites)
264064 0.263 0.000 1.546 0.000 buildmap.py:621(WriteSprite)
434 0.023 0.000 1.365 0.003 buildmap.py:312(DupeSprites)
191732 1.348 0.000 1.364 0.000 buildmap.py:888(MapCrypt)
18784 0.095 0.000 1.335 0.000 buildmap.py:276(DupeSprite)
273334 0.955 0.000 1.327 0.000 buildmap.py:80(__init__)
161795 0.844 0.000 1.229 0.000 buildmap.py:23(__init__)
39877 0.068 0.000 0.991 0.000 buildmap.py:689(GetContainingSectorNearby)
217 0.046 0.000 0.782 0.004 buildmap.py:589(WriteSectors)
138390 0.098 0.000 0.736 0.000 buildmap.py:583(WriteSector)
273334 0.297 0.000 0.543 0.000 buildmap.py:380(AppendSprite)
434 0.046 0.000 0.537 0.001 buildmap.py:303(SwapAllSprites)
127872 0.272 0.000 0.515 0.000 buildmap.py:660(GetSectorInfo)
127872 0.067 0.000 0.408 0.000 buildmap.py:862(PointIsInSector)
54918 0.057 0.000 0.406 0.000 buildmap.py:267(SwapSprites)
55 0.000 0.000 0.390 0.007 buildmap.py:855(WriteSprites)
152980 0.329 0.000 0.342 0.000 buildmap.py:869(PointIsInShape)
917728 0.247 0.000 0.332 0.000 buildmap.py:377(AppendWall)
273354 0.220 0.000 0.220 0.000 buildmap.py:13(__init__)
434 0.036 0.000 0.122 0.000 buildmap.py:320(ReduceSprites)
138390 0.039 0.000 0.053 0.000 buildmap.py:374(AppendSector)
18784 0.027 0.000 0.043 0.000 buildmap.py:99(__copy__)
updated profiling results
Ran 7 tests in 30.850s
9 0.018 0.002 25.782 2.865 grp.py:233(Randomize)
217 0.001 0.000 16.249 0.075 buildmap.py:886(LoadMap)
217 0.004 0.000 16.242 0.075 buildmap.py:118(__init__)
162 0.001 0.000 13.180 0.081 buildmap.py:633(ReadData)
217 0.540 0.002 10.022 0.046 buildmap.py:590(ReadWalls)
917728 1.138 0.000 9.139 0.000 buildmap.py:417(GetWall)
217 0.002 0.000 8.704 0.040 buildmap.py:186(Randomize)
217 0.022 0.000 8.688 0.040 buildmap.py:199(_Randomize)
217 0.008 0.000 6.418 0.030 buildmap.py:644(WriteData)
217 0.295 0.001 3.974 0.018 buildmap.py:603(WriteWalls)
217 0.194 0.001 3.967 0.018 buildmap.py:609(ReadSprites)
917728 0.609 0.000 3.680 0.000 buildmap.py:597(WriteWall)
917728 2.489 0.000 3.507 0.000 buildmap.py:58(__init__)
273314 0.387 0.000 3.227 0.000 buildmap.py:431(GetSprite)
55 0.000 0.000 3.029 0.055 buildmap.py:839(ReadData)
217 0.086 0.000 2.212 0.010 buildmap.py:571(ReadSectors)
138390 0.186 0.000 2.072 0.000 buildmap.py:403(GetSector)
217 0.093 0.000 1.626 0.007 buildmap.py:627(WriteSprites)
264064 0.261 0.000 1.532 0.000 buildmap.py:616(WriteSprite)
434 0.022 0.000 1.368 0.003 buildmap.py:309(DupeSprites)
191732 1.326 0.000 1.341 0.000 buildmap.py:878(MapCrypt)
18784 0.096 0.000 1.339 0.000 buildmap.py:273(DupeSprite)
273334 0.933 0.000 1.296 0.000 buildmap.py:77(__init__)
161795 0.800 0.000 1.196 0.000 buildmap.py:23(__init__)
39877 0.069 0.000 0.993 0.000 buildmap.py:683(GetContainingSectorNearby)
217 0.046 0.000 0.786 0.004 buildmap.py:584(WriteSectors)
138390 0.099 0.000 0.740 0.000 buildmap.py:578(WriteSector)
I did this
class Sector:
def __init__(self, data):
self.__dict__ = data
class Wall:
def __init__(self, data):
self.__dict__ = data
class Sprite:
def __init__(self, data):
self.__dict__ = data
def __copy__(self) -> 'Sprite':
cls = self.__class__
copied = cls.__new__(cls)
copied.__dict__.update(self.__dict__)
copied.pos = copied.pos[:]
copied.texcoords = copied.texcoords[:]
copied.velocity = copied.velocity[:]
return copied
and got this
Ran 7 tests in 25.344s
9 0.029 0.003 20.643 2.294 grp.py:233(Randomize)
217 0.001 0.000 11.024 0.051 buildmap.py:820(LoadMap)
217 0.004 0.000 11.017 0.051 buildmap.py:52(__init__)
217 0.003 0.000 8.577 0.040 buildmap.py:120(Randomize)
162 0.001 0.000 8.569 0.053 buildmap.py:567(ReadData)
217 0.023 0.000 8.560 0.039 buildmap.py:133(_Randomize)
217 0.514 0.002 6.865 0.032 buildmap.py:524(ReadWalls)
217 0.006 0.000 6.437 0.030 buildmap.py:578(WriteData)
917728 0.994 0.000 6.001 0.000 buildmap.py:351(GetWall)
217 0.293 0.001 3.984 0.018 buildmap.py:537(WriteWalls)
917728 0.595 0.000 3.691 0.000 buildmap.py:531(WriteWall)
217 0.175 0.001 2.843 0.013 buildmap.py:543(ReadSprites)
55 0.000 0.000 2.415 0.044 buildmap.py:773(ReadData)
273314 0.342 0.000 2.062 0.000 buildmap.py:365(GetSprite)
217 0.085 0.000 1.616 0.007 buildmap.py:561(WriteSprites)
264064 0.256 0.000 1.529 0.000 buildmap.py:550(WriteSprite)
191732 1.335 0.000 1.351 0.000 buildmap.py:812(MapCrypt)
217 0.081 0.000 1.268 0.006 buildmap.py:505(ReadSectors)
434 0.024 0.000 1.205 0.003 buildmap.py:243(DupeSprites)
18784 0.094 0.000 1.174 0.000 buildmap.py:207(DupeSprite)
138390 0.210 0.000 1.132 0.000 buildmap.py:337(GetSector)
39877 0.067 0.000 0.828 0.000 buildmap.py:617(GetContainingSectorNearby)
217 0.048 0.000 0.807 0.004 buildmap.py:518(WriteSectors)
138390 0.098 0.000 0.759 0.000 buildmap.py:512(WriteSector)
273334 0.273 0.000 0.606 0.000 buildmap.py:311(AppendSprite)
434 0.047 0.000 0.555 0.001 buildmap.py:234(SwapAllSprites)
54918 0.058 0.000 0.420 0.000 buildmap.py:198(SwapSprites)
127872 0.068 0.000 0.406 0.000 buildmap.py:786(PointIsInSector)
55 0.000 0.000 0.392 0.007 buildmap.py:779(WriteSprites)
127872 0.288 0.000 0.355 0.000 buildmap.py:588(GetSectorInfo)
917728 0.264 0.000 0.350 0.000 buildmap.py:308(AppendWall)
152980 0.325 0.000 0.337 0.000 buildmap.py:793(PointIsInShape)
273354 0.305 0.000 0.305 0.000 buildmap.py:13(__init__)
917728 0.138 0.000 0.138 0.000 buildmap.py:25(__init__)
434 0.038 0.000 0.129 0.000 buildmap.py:251(ReduceSprites)
138390 0.041 0.000 0.055 0.000 buildmap.py:305(AppendSector)
18784 0.025 0.000 0.045 0.000 buildmap.py:30(__copy__)
273334 0.042 0.000 0.042 0.000 buildmap.py:28(__init__)
161795 0.026 0.000 0.026 0.000 buildmap.py:22(__init__)
so grp.py:233(Randomize) went from 25 seconds down to 20 seconds, and LoadMap went from 16 seconds down to 11, I think it's worth doing
I think the Wall constructor was the slowest one