You do not need to check every single possibility. For your set use $\{+1, -1\}$.
Suppose $B$ is commutative, i.e. $B(a,b)=B(b,a)$ for all $a,b\in \{\pm1\}$, and associative . Then if we put $B(a,a)=x_a$ and $B(a,-a)=B(-a,a)=y$ (note the latter is independent of $a$). The triple $x_{\pm1},y$ is enough to completely determine $B$. The only non-trivial associativity equation in this case yields
$$
\begin{aligned}
B(x_y,-y)&=B(B(y,y), -y)=B(y,B(y,-y))=B(y,y)=x_y\\
B(x_{-y},y)&=B(B(-y,-y), y)=B(-y,B(-y,y))=B(-y,y)=y
\end{aligned}
$$
The possible solutions are (1) $x_y=-x_{-y}=y$, (2) $x_y=x_{-y}=y$, (3) $x_y=x_{-y}=-y$. And these are the only possibilities.
So programatically, if $B(1,-1)=B(-1,1)$, simply calculate $x_{+1}, x_{-1}, y$ and check if $x_y=y$ (case 1 and 2 together), or else if $x_y=x_{-y}$.
Suppose $B$ is NOT commutative but associative. Then $B(a,-a)=-B(-a,a)$. Define $x_a=B(a,a)$ and $y=B(1,-1)$. Now associativity gives
$$
B(x_a,a)=B(B(a,a),a)=B(a,B(a,a))=B(a,x_a)
$$
meaning $a,x_a$ commute. This in turn means, $x_a=a$ necessarily.
Before we continue, note that the equalities
$$
\begin{aligned}
y&=B(1,y)=-B(-1,-y)=B(y,-1)=-B(-y,1)\\
1&=B(y,1)=B(1,-y)=-B(-y,-1)=-B(-1,y)
\end{aligned}
$$
are tautologically true no matter what $y$ is. Writting the most general associativity equality
$$
B(B(a,b),c)=B(a, B(b,c))
$$
assuming not all $a,b,c$ are the same, we have the following possibilities, $a=b=-c$, $a=-b=c$ and $-a=b=c$. This leads to three associativity relation
$$
\begin{aligned}
&(\mathrm{sgn}\: a)y=B(a,-a)=B(B(a,a),-a)=B(a, B(a,-a))=B(a,(\mathrm{sgn}\: a)y)\\
&B((\mathrm{sgn}\: a)y,a)=B(B(a,-a),a)=B(a, B(-a,a))=B(a, -(\mathrm{sgn}\: a)y)\\
&B(-(\mathrm{sgn}\: a)y,a)=B(B(-a,a),a)=B(-a,B(a,a))=B(-a,a)=-(\mathrm{sgn}\: a)y
\end{aligned}
$$
all of which are tautologically true. This means we are completely free to choose $y$ as we please. So programatically, if $y=B(1,-1)\neq B(-1,1)$, then simply check if $B(1,1)=1$ and $B(-1,-1)$, because that's the only possibility.
Assuming I have not done any stupid mistakes (which I'm quite afraid might have happened), you should be able to rule whether a binary relation $B$ is associative or not with like four if-clauses. I'm too lazy to actually count how many binary relations I just created, but it's quite straightforward to do that now.