By generating a test statistic on the dataset and then for many random permutations of that data, a permutation test is used to assess the statistical significance of a model. The initial test statistic value should fall into one of the null hypothesis distribution's tails if the model is significant. To find the p-value, you need to just count the number of test-statistics that are as severe as or more extreme than the initial test statistics and then divide that number by the total number of test-statistics we computed. Given that the null hypothesis is true, the P-value is the chance of getting a result at least as severe as the test statistic.