When I create a random image having just white and black dots using random function for determining whether a particular pixel is black or white and it is done in a 1 bit depth
And I save that image in Jpeg
Using the command
JPEG is using 8 bits per sample while PNG is using 1 bit per sample, for black-and-white images, before compression. So even though JPEG compression is generally more effective than PNG's lossless compression, in your tests PNG has an 8 to 1 head start.